ref: 2fd33bae7d96a5cebd9dbb5040d9b09af65183d4
parent: 2df44c2d55f305fd1a66ada8fb1d4abababbaa39
author: Erik de Castro Lopo <erikd@mega-nerd.com>
date: Thu Jul 10 05:21:14 EDT 2008
src/samplerate.c : Fix a valgrind warning which occured when the call back function returns a count of zero without modifying the pointer value.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-07-10 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * src/samplerate.c
+ Fix a valgrind warning which occured when the call back function returns
+ a count of zero without modifying the pointer value. Thanks to Paul Kelly.
+
2008-07-09 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/src_sinc.c
--- a/src/samplerate.c
+++ b/src/samplerate.c
@@ -132,16 +132,13 @@
if (data == NULL)
return SRC_ERR_BAD_DATA ;
- /* Check src_ratio is in range. */
- if (is_bad_src_ratio (data->src_ratio))
- return SRC_ERR_BAD_SRC_RATIO ;
-
/* And that data_in and data_out are valid. */
if (data->data_in == NULL || data->data_out == NULL)
return SRC_ERR_BAD_DATA_PTR ;
- if (data->data_in == NULL)
- data->input_frames = 0 ;
+ /* Check src_ratio is in range. */
+ if (is_bad_src_ratio (data->src_ratio))
+ return SRC_ERR_BAD_SRC_RATIO ;
if (data->input_frames < 0)
data->input_frames = 0 ;
@@ -226,7 +223,11 @@
while (output_frames_gen < frames)
{
if (src_data.input_frames == 0)
- { float *ptr ;
+ { /* Use a dummy array for the case where the callback function
+ ** returns without setting the ptr.
+ */
+ float dummy [1] ;
+ float *ptr = dummy ;
src_data.input_frames = psrc->callback_func (psrc->user_callback_data, &ptr) ;
src_data.data_in = ptr ;