diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2015-01-28 18:12:15 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2015-01-30 20:55:46 +1100 |
commit | 8a41dfe2cbd05e08343ad11830790326ade75a0b (patch) | |
tree | 91384f0a0e383f7f1ed2ff9163cdee2fc686b3ee | |
parent | be5b47af580bcb45617c5eb58fbffbe54925eab2 (diff) |
src/(float32|double64).c : Fix potential divide by 0.
-rw-r--r-- | src/double64.c | 7 | ||||
-rw-r--r-- | src/float32.c | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/double64.c b/src/double64.c index ce60699..b318ea8 100644 --- a/src/double64.c +++ b/src/double64.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com> +** Copyright (C) 1999-2015 Erik de Castro Lopo <erikd@mega-nerd.com> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -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 ; diff --git a/src/float32.c b/src/float32.c index 89bcf6b..100c149 100644 --- a/src/float32.c +++ b/src/float32.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com> +** Copyright (C) 1999-2015 Erik de Castro Lopo <erikd@mega-nerd.com> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU Lesser General Public License as published by @@ -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 ; |