Bug 1207478 - P1. Prevent microseconds calculation overflow. r=gerald, a=sylvestre
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 24 Sep 2015 09:29:54 +1000
changeset 297843 ae10b93c046541a6681d01fe6c6421f4523001f2
parent 297842 6458f1f2c29edf1df7c2212ca51fef72177a90e9
child 297844 bfa5ce9f77b2be23202fd2e2390cc1cb996bbb21
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, sylvestre
bugs1207478, 294441
milestone43.0a2
Bug 1207478 - P1. Prevent microseconds calculation overflow. r=gerald, a=sylvestre This leaves us safe until year 294441 (assuming unix timestamp).
media/libstagefright/binding/include/mp4_demuxer/MoofParser.h
--- a/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/MoofParser.h
@@ -30,17 +30,19 @@ public:
     , mTimescale(0)
     , mDuration(0)
   {
   }
   explicit Mvhd(Box& aBox);
 
   Microseconds ToMicroseconds(int64_t aTimescaleUnits)
   {
-    return aTimescaleUnits * 1000000ll / mTimescale;
+    int64_t major = aTimescaleUnits / mTimescale;
+    int64_t remainder = aTimescaleUnits % mTimescale;
+    return major * 1000000ll + remainder * 1000000ll / mTimescale;
   }
 
   uint64_t mCreationTime;
   uint64_t mModificationTime;
   uint32_t mTimescale;
   uint64_t mDuration;
 };