File 0020-src-float32-double64-.c-Fix-potential-divide-by-0.patch of Package libsndfile.4961

From 8a41dfe2cbd05e08343ad11830790326ade75a0b Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Wed, 28 Jan 2015 18:12:15 +1100
Subject: [PATCH] src/(float32|double64).c : Fix potential divide by 0.

---
 src/double64.c |    5 +++++
 src/float32.c  |    5 +++++
 2 files changed, 10 insertions(+)

--- a/src/double64.c
+++ b/src/double64.c
@@ -91,6 +91,11 @@ int
 double64_init	(SF_PRIVATE *psf)
 {	static int double64_caps ;
 
+	if (psf->sf.channels < 1)
+	{	psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ;
+		return SFE_INTERNAL ;
+		} ;
+
 	double64_caps = double64_get_capability (psf) ;
 
 	psf->blockwidth = sizeof (double) * psf->sf.channels ;
--- a/src/float32.c
+++ b/src/float32.c
@@ -88,6 +88,11 @@ int
 float32_init	(SF_PRIVATE *psf)
 {	static int float_caps ;
 
+	if (psf->sf.channels < 1)
+	{	psf_log_printf (psf, "float32_init : internal error : channels = %d\n", psf->sf.channels) ;
+		return SFE_INTERNAL ;
+		} ;
+
 	float_caps = float32_get_capability (psf) ;
 
 	psf->blockwidth = sizeof (float) * psf->sf.channels ;
openSUSE Build Service is sponsored by