From: <sv...@op...> - 2024-11-18 20:01:41
|
Author: sagamusix Date: Mon Nov 18 21:01:34 2024 New Revision: 22226 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22226 Log: [Fix] Tuning: Apply a (hopefully small enough) epsilon to tuning ratio setting to avoid NaN and inf results in tuning frequency calculation. Found with afl++ + ubsan. Modified: trunk/OpenMPT/soundlib/tuning.h Modified: trunk/OpenMPT/soundlib/tuning.h ============================================================================== --- trunk/OpenMPT/soundlib/tuning.h Mon Nov 18 20:57:24 2024 (r22225) +++ trunk/OpenMPT/soundlib/tuning.h Mon Nov 18 21:01:34 2024 (r22226) @@ -224,7 +224,8 @@ static bool IsValidRatio(RATIOTYPE ratio) { - return (ratio > static_cast<RATIOTYPE>(0.0)); + // Arbitrary epsilon > 0 to avoid NaNs and infinite values in ratio calculation + return (ratio > static_cast<RATIOTYPE>(0.02f)); } private: |