On Fri, Sep 20, 2013 at 08:16:58PM +0200, Alexandra Khirnova wrote:
> --- a/libavcodec/bitstream.c
> +++ b/libavcodec/bitstream.c
> @@ -102,16 +102,17 @@ void avpriv_copy_bits(PutBitContext *pb, const uint8_t
> *src, int length)
> static int alloc_table(VLC *vlc, int size, int use_static)
> {
> - int index = vlc->table_size;
> + int index = vlc->table_size, err;
>
> vlc->table_size += size;
> if (vlc->table_size > vlc->table_allocated) {
> if (use_static)
> return AVERROR_BUG;
> vlc->table_allocated += (1 << vlc->bits);
> - vlc->table = av_realloc(vlc->table, sizeof(VLC_TYPE) * 2 *
> vlc->table_allocated);
> - if (!vlc->table)
> - return AVERROR(ENOMEM);
> + if ((err = av_reallocp(&vlc->table,
> + sizeof(VLC_TYPE) * 2 *
> + vlc->table_allocated)) < 0)
> + return err;
nit: The variable could be declared with smaller scope.
> --- a/libavcodec/g2meet.c
> +++ b/libavcodec/g2meet.c
> @@ -236,16 +236,15 @@ static int jpg_decode_data(JPGContext *c, int width,
> int height,
>
> - tmp = av_realloc(c->buf, src_size + FF_INPUT_BUFFER_PADDING_SIZE);
> - if (!tmp)
> - return AVERROR(ENOMEM);
> - c->buf = tmp;
> + if ((ret = av_reallocp(&c->buf,
> + src_size +
> + FF_INPUT_BUFFER_PADDING_SIZE)) < 0)
no need to break this line
> --- a/libavcodec/h264_mp4toannexb_bsf.c
> +++ b/libavcodec/h264_mp4toannexb_bsf.c
> @@ -84,8 +83,7 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx,
> const int padding)
> while (unit_nb--) {
> - void *tmp;
> -
> + int err;
> unit_size = AV_RB16(extradata);
> total_size += unit_size + 4;
Maintain the style and keep the empty line after the variable
declarations.
> --- a/libavcodec/libtheoraenc.c
> +++ b/libavcodec/libtheoraenc.c
> @@ -68,16 +67,19 @@ static int concatenate_packet(unsigned int* offset,
> } else if (newsize < avc_context->extradata_size) {
> message = "extradata_size would overflow";
> } else {
> - newdata = av_realloc(avc_context->extradata, newsize);
> - if (!newdata)
> + int err;
> + if ((err = av_reallocp(&avc_context->extradata, newsize)) < 0) {
> message = "av_realloc failed";
> + av_log(avc_context, AV_LOG_ERROR,
> + "concatenate_packet failed: %s\n", message);
> + return err;
> +
> }
> if (message) {
> av_log(avc_context, AV_LOG_ERROR, "concatenate_packet failed: %s\n",
> message);
> return -1;
> }
This block is weird, so you will have to do a bit more extensive changes
here. I would suggest initializing "err" to AVERROR(INVALIDDATA) above,
just setting message in the block you change and returning "err" in the
block that checks "message".
> --- a/libavcodec/shorten.c
> +++ b/libavcodec/shorten.c
> @@ -135,26 +133,21 @@ static int allocate_buffers(ShortenContext *s)
> - tmp_ptr = av_realloc(s->decoded_base[chan], (s->blocksize +
> s->nwrap) *
> - sizeof(s->decoded_base[0][0]));
> - if (!tmp_ptr)
> - return AVERROR(ENOMEM);
> - s->decoded_base[chan] = tmp_ptr;
> + if ((err = av_reallocp(&s->decoded_base[chan], (s->blocksize +
> s->nwrap) *
> + sizeof(s->decoded_base[0][0]))) < 0)
Indentation is off.
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -62,7 +62,7 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t
> min_size)
>
> - ptr = av_realloc(ptr, min_size);
> + av_reallocp(&ptr, min_size);
> /* we could set this to the unmodified min_size but this is safer
> * if the user lost the ptr and uses NULL now
> */
This allocation is unchecked. You should fix that.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel