shithub: aacenc

Download patch

ref: 10655c15c4d96dc52679a4f0f66ccb2d94c9a277
parent: 764ddc7685376c05b737919ac4b6f0c2c13c9204
parent: ba794fcc398e5cd98d43b2148b2420c6df4ecdea
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Jul 23 06:27:19 EDT 2018

Merge pull request #17 from knik0/div0_issue14

Fix division by zero errors

--- 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