[vlc-commits] commit: Put size check before data dereference ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sun Oct 10 12:11:41 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 10 12:46:27 2010 +0300| [ef2f7b9d70d4ea370faf584e58f547e569a14a37] | committer: Rémi Denis-Courmont 

Put size check before data dereference

I think that's a good pattern to follow.
In this particular case, there was no bug however.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef2f7b9d70d4ea370faf584e58f547e569a14a37
---

 modules/demux/ps.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/demux/ps.h b/modules/demux/ps.h
index 4d75b74..23bcead 100644
--- a/modules/demux/ps.h
+++ b/modules/demux/ps.h
@@ -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;
         }



More information about the vlc-commits mailing list