- return -1;
- }
-
- c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
- c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
- c->bx = (c->width + c->bw - 1) / c->bw;
- c->by = (c->height+ c->bh - 1) / c->bh;
- }
-
- if (c->decode_intra == NULL) {
- av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
- return -1;
- }
-
- if (c->comp == 0) { //Uncompressed data
- memcpy(c->decomp_buf, buf, len);
- c->decomp_size = 1;
- } else { // ZLIB-compressed data
+ return AVERROR_UNKNOWN;
+ }
+
+ tmp = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
+ if (!tmp)
+ return AVERROR(ENOMEM);
+ c->cur = tmp;
+ tmp = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
+ if (!tmp)
+ return AVERROR(ENOMEM);
+ c->prev = tmp;
+ c->bx = (c->width + c->bw - 1) / c->bw;
+ c->by = (c->height + c->bh - 1) / c->bh;
+ }
+
+ if (!c->decode_intra) {
+ av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (c->comp == 0) { // uncompressed data
+ if (c->decomp_size < len) {
+ av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
+ return AVERROR_INVALIDDATA;
+ }
+ memcpy(c->decomp_buf, buf, len);
+ } else { // ZLIB-compressed data