[FFmpeg-devel] [PATCH] IFF: Add error checking to byterun1 decoder

Sebastian Vater cdgs.basty
Sun May 23 17:31:46 CEST 2010


Ronald S. Bultje a ?crit :
> Hi,
>
> On Sun, May 16, 2010 at 6:35 PM, Sebastian Vater
> <cdgs.basty at googlemail.com> wrote:
>   
>> Stefano Sabatini a ?crit :
>>     
>>> On date Monday 2010-05-17 00:08:55 +0200, Sebastian Vater encoded:
>>>
>>>       
>>>> @@ -306,7 +313,7 @@ static int decode_frame_byterun1(AVCodecContext *avctx,
>>>>      const uint8_t *buf = avpkt->data;
>>>>      int buf_size = avpkt->size;
>>>>      const uint8_t *buf_end = buf+buf_size;
>>>> -    int y, plane;
>>>> +    int y, plane, err;
>>>>
>>>>      if (avctx->reget_buffer(avctx, &s->frame) < 0){
>>>>          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
>>>> @@ -319,7 +326,11 @@ static int decode_frame_byterun1(AVCodecContext *avctx,
>>>>                  uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
>>>>                  memset(row, 0, avctx->width);
>>>>                  for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) {
>>>> -                    buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end);
>>>> +                    if ((err = decode_byterun(s->planebuf, s->planesize, buf, buf_end)) < 0) {
>>>> +                        av_log(avctx, AV_LOG_ERROR, "IFF byterun1 stream truncated\n");
>>>> +                        return err;
>>>> +                    }
>>>> +                    buf += err;
>>>>
>>>>         
>>> buf += err looks strange, buf += ret should look saner.
>>>
>>>       
>> Fixed by changing err(or) to res(ult).
>>     
> [..]
>   
>> @@ -336,7 +351,11 @@ static int decode_frame_byterun1(AVCodecContext *avctx,
>>      } else {
>>          for(y = 0; y < avctx->height ; y++ ) {
>>              uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
>> -            buf += decode_byterun(row, avctx->width, buf, buf_end);
>> +            if ((res = decode_byterun(row, avctx->width, buf, buf_end)) < 0) {
>> +                av_log(avctx, AV_LOG_ERROR, "IFF byterun1 stream truncated\n");
>> +                return res;
>> +            }
>> +            buf += res;
>>          }
>>      }
>>     
>
>
>   
> And I agree with Stefano that the log msg should be in
> decode_byterun() also, a goto here is fine with me.
>   

Fixed. For preventing the function become non-inlined then I have added
av_always_inline to it. I also pass AVCodecContext
to it.
Hope this new patch is fine.

-- 

Best regards,
                   :-) Basty/CDGS (-:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: iff-byterun1-error.patch
Type: text/x-patch
Size: 4839 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100523/02c830d9/attachment.bin>



More information about the ffmpeg-devel mailing list