From 875c22233b8abccc6130a8be2971cc597c22b249 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sun, 6 Dec 2009 00:38:50 +0100 Subject: [PATCH] Protect against libfaad returning NULL. --- apps/codecs/aac.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c index 6046035..7d706f4 100644 --- a/apps/codecs/aac.c +++ b/apps/codecs/aac.c @@ -53,6 +53,7 @@ enum codec_status codec_main(void) int err; uint32_t s = 0; unsigned char c = 0; + void *ret; /* Generic codec initialisation */ ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); @@ -179,11 +180,10 @@ next_track: buffer=ci->request_buffer(&n,sample_byte_size); /* Decode one block - returned samples will be host-endian */ - NeAACDecDecode(decoder, &frame_info, buffer, n); - /* Ignore return value, we access samples in the decoder struct - * directly. - */ - if (frame_info.error > 0) { + ret = NeAACDecDecode(decoder, &frame_info, buffer, n); + + /* NeAACDecDecode may sometimes return NULL without setting error. */ + if (ret == NULL || frame_info.error > 0) { LOGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); err = CODEC_ERROR; goto done; -- 1.6.5.3