From 70f2314df06e9980b99b66fe07372066a630ae73 Mon Sep 17 00:00:00 2001 From: Måns Rullgård Date: Sat, 26 Jun 2010 14:34:15 +0000 Subject: pcx: convert VLAs to malloc/free Originally committed as revision 23796 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/pcx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'libavcodec/pcx.c') diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 2174184bce..072d136d81 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -87,6 +87,8 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, bytes_per_scanline; uint8_t *ptr; uint8_t const *bufstart = buf; + uint8_t *scanline; + int ret = -1; if (buf[0] != 0x0a || buf[1] > 5) { av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n"); @@ -154,9 +156,11 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, ptr = p->data[0]; stride = p->linesize[0]; - if (nplanes == 3 && bits_per_pixel == 8) { - uint8_t scanline[bytes_per_scanline]; + scanline = av_malloc(bytes_per_scanline); + if (!scanline) + return AVERROR(ENOMEM); + if (nplanes == 3 && bits_per_pixel == 8) { for (y=0; ypicture; *data_size = sizeof(AVFrame); - return buf - bufstart; + ret = buf - bufstart; +end: + av_free(scanline); + return ret; } static av_cold int pcx_end(AVCodecContext *avctx) { -- cgit v1.2.3