oggstream: fix a few left shifts operations on 32 bits cast to 64 bits
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 10 Apr 2014 09:33:46 +0000 (10:33 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 10 Apr 2014 10:06:00 +0000 (11:06 +0100)
This should not cause any actual bug since Theora and Daala have
a maximum shift of 31, and a packet duration of 2^31 seems very
implausible. But it fixes:

Coverity 1139804, 1139803, 1139802

ext/ogg/gstoggstream.c

index 7af157a..83a2ce5 100644 (file)
@@ -498,7 +498,7 @@ is_granulepos_keyframe_theora (GstOggStream * pad, gint64 granulepos)
   if (granulepos == (gint64) - 1)
     return FALSE;
 
-  frame_mask = (1 << pad->granuleshift) - 1;
+  frame_mask = (1ll << pad->granuleshift) - 1;
 
   return ((granulepos & frame_mask) == 0);
 }
@@ -1105,7 +1105,7 @@ packet_duration_flac (GstOggStream * pad, ogg_packet * packet)
     return 576 << (block_size_index - 2);
   }
   if (block_size_index >= 8) {
-    return 256 << (block_size_index - 8);
+    return 256ll << (block_size_index - 8);
   }
   if (block_size_index == 6 || block_size_index == 7) {
     guint len, bytes = (block_size_index - 6) + 1;
@@ -2195,7 +2195,7 @@ is_granulepos_keyframe_daala (GstOggStream * pad, gint64 granulepos)
   if (granulepos == (gint64) - 1)
     return FALSE;
 
-  frame_mask = (1 << pad->granuleshift) - 1;
+  frame_mask = (1ll << pad->granuleshift) - 1;
 
   return ((granulepos & frame_mask) == 0);
 }