shithub: aacdec

Download patch

ref: b9862e2e3d585d1de25143b27ca19df79e9921c5
parent: a8dc3f8ce67f4069cfa4d5cf0fcc2c6e8ef2c2aa
author: Hugo Lefeuvre <hle@debian.org>
date: Sun May 5 06:31:12 EDT 2019

main: fix crash with unsupported MP4 files

aac_frame_decode returns NULL on failure.

decodeMP4file should consequently NULL-check NeAACDecDecode's return
pointer before doing anything with it. Not doing so leads to undefined
behavior (division by zero, NULL pointer dereference, etc.)

add missing NULL-check.

fixes #13.

--- a/frontend/main.c
+++ b/frontend/main.c
@@ -915,6 +915,11 @@
 
         sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, mp4config.bitbuf.data, mp4config.bitbuf.size);
 
+        if (!sample_buffer) {
+            /* unable to decode file, abort */
+            break;
+        }
+
         if (adts_out == 1)
         {
             adtsData = MakeAdtsHeader(&adtsDataSize, &frameInfo, 0);
@@ -1365,4 +1370,4 @@
 #else
     return faad_main(argc, argv);
 #endif
-}
\ No newline at end of file
+}