History

zerocodec: Fix memleak in decode_frame

If there was a failure inflating, or reinitializing the zstream, the current frame's buffer would be lost.

Derek Buitenhuis committed 14 years ago

Commit fcf550c1 parent d6124d01 file · +6 −5Browse files

Unified · Split

libavcodec/zerocodec.c+6−5
@@ -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;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t