Mercurial > libavcodec.hg
comparison mpeg12.c @ 3045:c5e521489fdf libavcodec
Off by one fix to prevent possible segfault. Patch by jwestfall at surrealistic dot net.
author | banan |
---|---|
date | Sat, 14 Jan 2006 17:43:22 +0000 |
parents | 0b546eab515d |
children | befacb1cb573 |
comparison
equal
deleted
inserted
replaced
3044:ed98beb48872 | 3045:c5e521489fdf |
---|---|
2176 static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) | 2176 static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) |
2177 { | 2177 { |
2178 const uint8_t *buf_ptr= *pbuf_ptr; | 2178 const uint8_t *buf_ptr= *pbuf_ptr; |
2179 | 2179 |
2180 buf_ptr++; //gurantees that -1 is within the array | 2180 buf_ptr++; //gurantees that -1 is within the array |
2181 buf_end -= 2; // gurantees that +2 is within the array | 2181 buf_end -= 3; // gurantees that +3 is within the array |
2182 | 2182 |
2183 while (buf_ptr < buf_end) { | 2183 while (buf_ptr < buf_end) { |
2184 if(*buf_ptr==0){ | 2184 if(*buf_ptr==0){ |
2185 while(buf_ptr < buf_end && buf_ptr[1]==0) | 2185 while(buf_ptr < buf_end && buf_ptr[1]==0) |
2186 buf_ptr++; | 2186 buf_ptr++; |
2190 return buf_ptr[2] + 0x100; | 2190 return buf_ptr[2] + 0x100; |
2191 } | 2191 } |
2192 } | 2192 } |
2193 buf_ptr += 2; | 2193 buf_ptr += 2; |
2194 } | 2194 } |
2195 buf_end += 2; //undo the hack above | 2195 buf_end += 3; //undo the hack above |
2196 | 2196 |
2197 *pbuf_ptr = buf_end; | 2197 *pbuf_ptr = buf_end; |
2198 return -1; | 2198 return -1; |
2199 } | 2199 } |
2200 | 2200 |