If there was a failure inflating, or reinitializing the zstream, the current frame's buffer would be lost.
Unified · Split
| @@ -51,17 +51,17 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, · 50 unmodified lines | |||
| 51 | pic->pict_type = AV_PICTURE_TYPE_P; | 51 | pic->pict_type = AV_PICTURE_TYPE_P; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | if (avctx->get_buffer(avctx, pic) < 0) { | ||
| 55 | av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); | ||
| 56 | return AVERROR(ENOMEM); | ||
| 57 | } | ||
| 58 | |||
| 59 | zret = inflateReset(zstream); | 54 | zret = inflateReset(zstream); |
| 60 | if (zret != Z_OK) { | 55 | if (zret != Z_OK) { |
| 61 | av_log(avctx, AV_LOG_ERROR, "Could not reset inflate: %d.\n", zret); | 56 | av_log(avctx, AV_LOG_ERROR, "Could not reset inflate: %d.\n", zret); |
| 62 | return AVERROR_INVALIDDATA; | 57 | return AVERROR_INVALIDDATA; |
| 63 | } | 58 | } |
| 64 | 59 | ||
| 60 | if (avctx->get_buffer(avctx, pic) < 0) { | ||
| 61 | av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); | ||
| 62 | return AVERROR(ENOMEM); | ||
| 63 | } | ||
| 64 | |||
| 65 | zstream->next_in = avpkt->data; | 65 | zstream->next_in = avpkt->data; |
| 66 | zstream->avail_in = avpkt->size; | 66 | zstream->avail_in = avpkt->size; |
| 67 | 67 | ||
| @@ -78,6 +78,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, · 10 unmodified lines | |||
| 78 | 78 | ||
| 79 | zret = inflate(zstream, Z_SYNC_FLUSH); | 79 | zret = inflate(zstream, Z_SYNC_FLUSH); |
| 80 | if (zret != Z_OK && zret != Z_STREAM_END) { | 80 | if (zret != Z_OK && zret != Z_STREAM_END) { |
| 81 | avctx->release_buffer(avctx, pic); | ||
| 81 | av_log(avctx, AV_LOG_ERROR, | 82 | av_log(avctx, AV_LOG_ERROR, |
| 82 | "Inflate failed with return code: %d.\n", zret); | 83 | "Inflate failed with return code: %d.\n", zret); |
| 83 | return AVERROR_INVALIDDATA; | 84 | return AVERROR_INVALIDDATA; |