Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: libavcodec/vorbisdec.c

Issue 9373002: Fix valgrind and asan memory leaks and crashes. (Closed) Base URL: ssh://gerrit.chromium.org:29418/chromium/third_party/ffmpeg.git@master
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libavcodec/utils.c ('k') | libavcodec/vp3.c » ('j') | libavcodec/vp3.c » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libavcodec/vorbisdec.c
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index f71d606dadf76d37cc6b161eb0fec869cb3a688a..443c0aac857ab26ba0f915bc333cf41557b85fa2 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -197,38 +197,46 @@ static void vorbis_free(vorbis_context *vc)
av_freep(&vc->channel_floors);
av_freep(&vc->saved);
- for (i = 0; i < vc->residue_count; i++)
- av_free(vc->residues[i].classifs);
- av_freep(&vc->residues);
+ if (vc->residues) {
+ for (i = 0; i < vc->residue_count; i++)
+ av_free(vc->residues[i].classifs);
+ av_freep(&vc->residues);
+ }
av_freep(&vc->modes);
ff_mdct_end(&vc->mdct[0]);
ff_mdct_end(&vc->mdct[1]);
- for (i = 0; i < vc->codebook_count; ++i) {
- av_free(vc->codebooks[i].codevectors);
- free_vlc(&vc->codebooks[i].vlc);
+ if (vc->codebooks) {
+ for (i = 0; i < vc->codebook_count; ++i) {
+ av_free(vc->codebooks[i].codevectors);
+ free_vlc(&vc->codebooks[i].vlc);
+ }
+ av_freep(&vc->codebooks);
}
- av_freep(&vc->codebooks);
- for (i = 0; i < vc->floor_count; ++i) {
- if (vc->floors[i].floor_type == 0) {
- av_free(vc->floors[i].data.t0.map[0]);
- av_free(vc->floors[i].data.t0.map[1]);
- av_free(vc->floors[i].data.t0.book_list);
- av_free(vc->floors[i].data.t0.lsp);
- } else {
- av_free(vc->floors[i].data.t1.list);
+ if (vc->floors) {
+ for (i = 0; i < vc->floor_count; ++i) {
+ if (vc->floors[i].floor_type == 0) {
+ av_free(vc->floors[i].data.t0.map[0]);
+ av_free(vc->floors[i].data.t0.map[1]);
+ av_free(vc->floors[i].data.t0.book_list);
+ av_free(vc->floors[i].data.t0.lsp);
+ } else {
+ av_free(vc->floors[i].data.t1.list);
+ }
}
+ av_freep(&vc->floors);
}
- av_freep(&vc->floors);
- for (i = 0; i < vc->mapping_count; ++i) {
- av_free(vc->mappings[i].magnitude);
- av_free(vc->mappings[i].angle);
- av_free(vc->mappings[i].mux);
+ if (vc->mappings) {
+ for (i = 0; i < vc->mapping_count; ++i) {
+ av_free(vc->mappings[i].magnitude);
+ av_free(vc->mappings[i].angle);
+ av_free(vc->mappings[i].mux);
+ }
+ av_freep(&vc->mappings);
}
- av_freep(&vc->mappings);
}
// Parse setup header -------------------------------------------------
« no previous file with comments | « libavcodec/utils.c ('k') | libavcodec/vp3.c » ('j') | libavcodec/vp3.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698