Skip to content

Commit

Permalink
main: fix crash with unsupported MP4 files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hlef committed May 5, 2019
1 parent a8dc3f8 commit b9862e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,11 @@ static int decodeMP4file(char *mp4file, char *sndfile, char *adts_fn, int to_std

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);
Expand Down Expand Up @@ -1365,4 +1370,4 @@ int main(int argc, char *argv[])
#else
return faad_main(argc, argv);
#endif
}
}

0 comments on commit b9862e2

Please sign in to comment.