History

avcodec/vorbisenc: fix leak if av_mallocz failed

In put_main_header(), av_mallocz() allocates memory to local variable buffer, buffer leaks if av_mallocz() to *out failed. Add av_free(buffer) before return error code.

Lidong Yan committed 1 year ago

Commit 40a3d351 parent 7d384861 file · +3 −1Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vorbisenc.c+3−1
@@ -740,8 +740,10 @@ static int put_main_header(vorbis_enc_context *venc, uint8_t **out) · 739 unmodified lines
740 740
741 len = hlens[0] + hlens[1] + hlens[2];741 len = hlens[0] + hlens[1] + hlens[2];
742 p = *out = av_mallocz(64 + len + len/255);742 p = *out = av_mallocz(64 + len + len/255);
743 if (!p)743 if (!p) {
744 av_freep(&buffer);
744 return AVERROR(ENOMEM);745 return AVERROR(ENOMEM);
746 }
745 747
746 *p++ = 2;748 *p++ = 2;
747 p += av_xiphlacing(p, hlens[0]);749 p += av_xiphlacing(p, hlens[0]);

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