From 530a867d51b9bac097286bc5d8947e91cf18d248 Mon Sep 17 00:00:00 2001 From: Robert Kausch Date: Mon, 20 Mar 2023 21:42:13 +0100 Subject: [PATCH] Fix division by zero in mp4trackdump. --- util/mp4trackdump.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/util/mp4trackdump.cpp b/util/mp4trackdump.cpp index 6d35c13..e334d45 100644 --- a/util/mp4trackdump.cpp +++ b/util/mp4trackdump.cpp @@ -38,7 +38,7 @@ static void DumpTrack ( MP4FileHandle mp4file, MP4TrackId tid ) MP4SampleId sid; MP4Duration time; uint32_t timescale; - uint64_t msectime; + uint64_t msectime = 0; uint64_t sectime, mintime, hrtime; @@ -49,9 +49,12 @@ static void DumpTrack ( MP4FileHandle mp4file, MP4TrackId tid ) for ( sid = 1; sid <= numSamples; sid++ ) { time = MP4GetSampleTime( mp4file, tid, sid ); - msectime = time; - msectime *= UINT64_C( 1000 ); - msectime /= timescale; + if ( timescale > 0 ) { + msectime = time; + msectime *= UINT64_C( 1000 ); + msectime /= timescale; + } + if ( msectime == 0 ) { hrtime = mintime = sectime = UINT64_C( 0 ); }