Package: faac / 1.29.9.2-2

0007-Fix-division-by-zero-errors.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From ba794fcc398e5cd98d43b2148b2420c6df4ecdea Mon Sep 17 00:00:00 2001
From: Fabian Greffrath <fabian@greffrath.com>
Date: Mon, 4 Jun 2018 15:38:10 +0200
Subject: [PATCH 7/7] Fix division by zero errors

Fixes: #14, thanks @project-repo
---
 frontend/input.c | 2 ++
 libfaac/frame.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/frontend/input.c b/frontend/input.c
index 685b806..93d3851 100644
--- a/frontend/input.c
+++ b/frontend/input.c
@@ -254,6 +254,8 @@ pcmfile_t *wav_open_read(const char *name, int rawinput)
     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;
diff --git a/libfaac/frame.c b/libfaac/frame.c
index 1566196..8407223 100644
--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -147,6 +147,8 @@ int FAACAPI faacEncSetConfiguration(faacEncHandle hpEncoder,
     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
-- 
2.18.0