diff options
author | James Zern <jzern@google.com> | 2016-09-27 14:29:18 -0700 |
---|---|---|
committer | James Zern <jzern@google.com> | 2016-09-27 14:29:18 -0700 |
commit | e61d82bd4fab408b32011568a52524b6a82bcf25 (patch) | |
tree | 64f17ee7f8d42f167e456740d51a464c3132e81d /vpxdec.c | |
parent | b3ebea5e8a849a15ab3eb4b44f1d909f4119c552 (diff) | |
download | libvpx-e61d82bd4fab408b32011568a52524b6a82bcf25.tar libvpx-e61d82bd4fab408b32011568a52524b6a82bcf25.tar.gz libvpx-e61d82bd4fab408b32011568a52524b6a82bcf25.tar.bz2 libvpx-e61d82bd4fab408b32011568a52524b6a82bcf25.zip |
vpxdec: avoid memory leaks under most conditions
avoids false positives when fuzzing with ASan+LSan.
Change-Id: I0d23b530ae80e5692b6951fe6e3690ea44159a5a
Diffstat (limited to 'vpxdec.c')
-rw-r--r-- | vpxdec.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -495,6 +495,7 @@ static int main_loop(int argc, const char **argv_) { vpx_codec_ctx_t decoder; char *fn = NULL; int i; + int ret = EXIT_FAILURE; uint8_t *buf = NULL; size_t bytes_in_buffer = 0, buffer_size = 0; FILE *infile; @@ -723,7 +724,7 @@ static int main_loop(int argc, const char **argv_) { dec_flags)) { fprintf(stderr, "Failed to initialize decoder: %s\n", vpx_codec_error(&decoder)); - return EXIT_FAILURE; + goto fail2; } if (!quiet) fprintf(stderr, "%s\n", decoder.name); @@ -733,7 +734,7 @@ static int main_loop(int argc, const char **argv_) { vpx_codec_control(&decoder, VP8_SET_POSTPROC, &vp8_pp_cfg)) { fprintf(stderr, "Failed to configure postproc: %s\n", vpx_codec_error(&decoder)); - return EXIT_FAILURE; + goto fail; } #endif @@ -752,7 +753,7 @@ static int main_loop(int argc, const char **argv_) { &ext_fb_list)) { fprintf(stderr, "Failed to configure external frame buffers: %s\n", vpx_codec_error(&decoder)); - return EXIT_FAILURE; + goto fail; } } @@ -861,7 +862,7 @@ static int main_loop(int argc, const char **argv_) { "Scaling is disabled in this configuration. " "To enable scaling, configure with --enable-libyuv\n", vpx_codec_error(&decoder)); - return EXIT_FAILURE; + goto fail; #endif } } @@ -972,17 +973,21 @@ static int main_loop(int argc, const char **argv_) { fprintf(stderr, "\n"); } - if (frames_corrupted) + if (frames_corrupted) { fprintf(stderr, "WARNING: %d frames corrupted.\n", frames_corrupted); + } else { + ret = EXIT_SUCCESS; + } fail: if (vpx_codec_destroy(&decoder)) { fprintf(stderr, "Failed to destroy decoder: %s\n", vpx_codec_error(&decoder)); - return EXIT_FAILURE; } +fail2: + if (!noblit && single_file) { if (do_md5) { MD5Final(md5_digest, &md5_ctx); @@ -1012,7 +1017,7 @@ fail: fclose(infile); free(argv); - return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS; + return ret; } int main(int argc, const char **argv_) { |