commit fcba53e32989d59cfd548deaaa6b2bfdc319751c
parent dbb0fdd59e3182dfae38f7a620384d4ae074e5a8
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 29 Jul 2026 11:07:17 +0200
fix double type issues
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/plugins/riff_extractor.c b/src/plugins/riff_extractor.c
@@ -59,7 +59,7 @@ fread_le (const char *data)
uint32_t result = 0;
for (unsigned int x = 0; x < 4; x++)
- result |= ((unsigned char) data[x]) << (x * 8);
+ result |= ((uint32_t) (unsigned char) data[x]) << (x * 8);
return result;
}
@@ -567,11 +567,19 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (fps > 0)
{
- unsigned int duration =
- (unsigned int) round_double ((double) avi.total_frames * 1000.0
- / (double) fps);
+ double dur = round_double ((double) avi.total_frames * 1000.0
+ / (double) fps);
+ unsigned int duration;
char format[256];
+ /* total_frames comes straight out of the file, so the product can
+ exceed UINT_MAX; converting an out-of-range double to an
+ unsigned int is undefined. */
+ if ( (dur < 0.0) ||
+ (dur > (double) UINT_MAX) )
+ dur = 0.0;
+ duration = (unsigned int) dur;
+
snprintf (format,
sizeof (format),
_ ("codec: %s, %u fps, %u ms"),