[FFmpeg-cvslog] r25003 - trunk/libavcodec/a64multienc.c
Benoit Fouet
benoit.fouet
Tue Aug 31 10:43:31 CEST 2010
On Tue, 31 Aug 2010 09:14:47 +0200 (CEST) bindhammer wrote:
> Author: bindhammer
> Date: Tue Aug 31 09:14:47 2010
> New Revision: 25003
>
> Log:
> Checking return values of av_malloc(z) and report an error in case.
>
> Modified:
> trunk/libavcodec/a64multienc.c
>
> Modified: trunk/libavcodec/a64multienc.c
> ==============================================================================
> --- trunk/libavcodec/a64multienc.c Tue Aug 31 02:33:56 2010 (r25002)
> +++ trunk/libavcodec/a64multienc.c Tue Aug 31 09:14:47 2010 (r25003)
> @@ -192,14 +192,21 @@ static av_cold int a64multi_init_encoder
>
> c->mc_frame_counter = 0;
> c->mc_use_5col = avctx->codec->id == CODEC_ID_A64_MULTI5;
> - c->mc_meta_charset = av_malloc (32000 * c->mc_lifetime * sizeof(int));
> - c->mc_best_cb = av_malloc (CHARSET_CHARS * 32 * sizeof(int));
> - c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int));
> - c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t));
> - c->mc_charset = av_malloc (0x800 * (INTERLACED+1) * sizeof(uint8_t));
> +
> + if(!(c->mc_meta_charset = av_malloc (32000 * c->mc_lifetime * sizeof(int))) ||
> + !(c->mc_best_cb = av_malloc (CHARSET_CHARS * 32 * sizeof(int))) ||
> + !(c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int))) ||
> + !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
> + !(c->mc_charset = av_malloc (0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
> + av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
> + return AVERROR(ENOMEM);
> + }
>
I didn't look carefully enough to know, but who's going to free the
ones for which the allocation worked?
> /* set up extradata */
> - avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE);
> + if(!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {
> + av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n");
> + return AVERROR(ENOMEM);
> + }
same here, is there somewhere where all of the aboves are freed?
--
Ben
More information about the ffmpeg-cvslog
mailing list