Revision 70f2314d

View differences:

libavcodec/pcx.c
87 87
                 bytes_per_scanline;
88 88
    uint8_t *ptr;
89 89
    uint8_t const *bufstart = buf;
90
    uint8_t *scanline;
91
    int ret = -1;
90 92

  
91 93
    if (buf[0] != 0x0a || buf[1] > 5) {
92 94
        av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
......
154 156
    ptr    = p->data[0];
155 157
    stride = p->linesize[0];
156 158

  
157
    if (nplanes == 3 && bits_per_pixel == 8) {
158
        uint8_t scanline[bytes_per_scanline];
159
    scanline = av_malloc(bytes_per_scanline);
160
    if (!scanline)
161
        return AVERROR(ENOMEM);
159 162

  
163
    if (nplanes == 3 && bits_per_pixel == 8) {
160 164
        for (y=0; y<h; y++) {
161 165
            buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
162 166

  
......
170 174
        }
171 175

  
172 176
    } else if (nplanes == 1 && bits_per_pixel == 8) {
173
        uint8_t scanline[bytes_per_scanline];
174 177
        const uint8_t *palstart = bufstart + buf_size - 769;
175 178

  
176 179
        for (y=0; y<h; y++, ptr+=stride) {
......
184 187
        }
185 188
        if (*buf++ != 12) {
186 189
            av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
187
            return -1;
190
            goto end;
188 191
        }
189 192

  
190 193
    } else if (nplanes == 1) {   /* all packed formats, max. 16 colors */
191
        uint8_t scanline[bytes_per_scanline];
192 194
        GetBitContext s;
193 195

  
194 196
        for (y=0; y<h; y++) {
......
202 204
        }
203 205

  
204 206
    } else {    /* planar, 4, 8 or 16 colors */
205
        uint8_t scanline[bytes_per_scanline];
206 207
        int i;
207 208

  
208 209
        for (y=0; y<h; y++) {
......
230 231
    *picture = s->picture;
231 232
    *data_size = sizeof(AVFrame);
232 233

  
233
    return buf - bufstart;
234
    ret = buf - bufstart;
235
end:
236
    av_free(scanline);
237
    return ret;
234 238
}
235 239

  
236 240
static av_cold int pcx_end(AVCodecContext *avctx) {

Also available in: Unified diff