shithub: aacenc

Download patch

ref: ba794fcc398e5cd98d43b2148b2420c6df4ecdea
parent: 764ddc7685376c05b737919ac4b6f0c2c13c9204
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Jun 4 11:38:10 EDT 2018

Fix division by zero errors

Fixes: #14, thanks @project-repo

--- a/frontend/input.c
+++ b/frontend/input.c
@@ -254,6 +254,8 @@
     sndf->channels = UINT16(wave.Format.nChannels);
     sndf->samplebytes = UINT16(wave.Format.wBitsPerSample) / 8;
     sndf->samplerate = UINT32(wave.Format.nSamplesPerSec);
+    if (!sndf->samplebytes || !sndf->channels)
+      return NULL;
     sndf->samples = riffsub.len / (sndf->samplebytes * sndf->channels);
   }
   return sndf;
--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -147,6 +147,8 @@
     TnsInit(hEncoder);
 
     /* Check for correct bitrate */
+    if (!hEncoder->sampleRate || !hEncoder->numChannels)
+        return 0;
     if (config->bitRate > (MaxBitrate(hEncoder->sampleRate) / hEncoder->numChannels))
         config->bitRate = MaxBitrate(hEncoder->sampleRate) / hEncoder->numChannels;
 #if 0