]> git.sesse.net Git - vlc/commitdiff
Put size check before data dereference
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 10 Oct 2010 09:46:27 +0000 (12:46 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 10 Oct 2010 10:11:33 +0000 (13:11 +0300)
I think that's a good pattern to follow.
In this particular case, there was no bug however.

modules/demux/ps.h

index 4d75b74e501e2e1f196c02b5fc778356b95f169a..23bcead383d21d336d2dc56f617c85c762d5d93a 100644 (file)
@@ -312,11 +312,11 @@ static inline int ps_pkt_size( const uint8_t *p, int i_peek )
     }
     else if( p[3] == 0xba )
     {
-        if( (p[4] >> 6) == 0x01 && i_peek >= 14 )
+        if( i_peek >= 14 && (p[4] >> 6) == 0x01 )
         {
             return 14 + (p[13]&0x07);
         }
-        else if( (p[4] >> 4) == 0x02 && i_peek >= 12 )
+        else if( i_peek >= 12 && (p[4] >> 4) == 0x02 )
         {
             return 12;
         }