Mercurial > libavcodec.hg
comparison pnm.c @ 2839:b857807dfe30 libavcodec
segfault fix
author | michael |
---|---|
date | Sun, 21 Aug 2005 15:44:59 +0000 |
parents | b2846918585c |
children | 95bac7109ff0 |
comparison
equal
deleted
inserted
replaced
2838:5e0c3833d208 | 2839:b857807dfe30 |
---|---|
196 case PIX_FMT_MONOBLACK: | 196 case PIX_FMT_MONOBLACK: |
197 n = (avctx->width + 7) >> 3; | 197 n = (avctx->width + 7) >> 3; |
198 do_read: | 198 do_read: |
199 ptr = p->data[0]; | 199 ptr = p->data[0]; |
200 linesize = p->linesize[0]; | 200 linesize = p->linesize[0]; |
201 if(s->bytestream + n*avctx->height > s->bytestream_end) | |
202 return -1; | |
201 for(i = 0; i < avctx->height; i++) { | 203 for(i = 0; i < avctx->height; i++) { |
202 memcpy(ptr, s->bytestream, n); | 204 memcpy(ptr, s->bytestream, n); |
203 s->bytestream += n; | 205 s->bytestream += n; |
204 ptr += linesize; | 206 ptr += linesize; |
205 } | 207 } |
209 unsigned char *ptr1, *ptr2; | 211 unsigned char *ptr1, *ptr2; |
210 | 212 |
211 n = avctx->width; | 213 n = avctx->width; |
212 ptr = p->data[0]; | 214 ptr = p->data[0]; |
213 linesize = p->linesize[0]; | 215 linesize = p->linesize[0]; |
216 if(s->bytestream + n*avctx->height*3/2 > s->bytestream_end) | |
217 return -1; | |
214 for(i = 0; i < avctx->height; i++) { | 218 for(i = 0; i < avctx->height; i++) { |
215 memcpy(ptr, s->bytestream, n); | 219 memcpy(ptr, s->bytestream, n); |
216 s->bytestream += n; | 220 s->bytestream += n; |
217 ptr += linesize; | 221 ptr += linesize; |
218 } | 222 } |
231 } | 235 } |
232 break; | 236 break; |
233 case PIX_FMT_RGBA32: | 237 case PIX_FMT_RGBA32: |
234 ptr = p->data[0]; | 238 ptr = p->data[0]; |
235 linesize = p->linesize[0]; | 239 linesize = p->linesize[0]; |
240 if(s->bytestream + avctx->width*avctx->height*4 > s->bytestream_end) | |
241 return -1; | |
236 for(i = 0; i < avctx->height; i++) { | 242 for(i = 0; i < avctx->height; i++) { |
237 int j, r, g, b, a; | 243 int j, r, g, b, a; |
238 | 244 |
239 for(j = 0;j < avctx->width; j++) { | 245 for(j = 0;j < avctx->width; j++) { |
240 r = *s->bytestream++; | 246 r = *s->bytestream++; |