shithub: libsamplerate

Download patch

ref: 8d472e29e9609d0237274d88b516eb1b9b3ef825
parent: 6327a3b3b24d83df68c763c182fc89eb915eac3e
author: Erik de Castro Lopo <[email protected]>
date: Tue Aug 6 13:44:37 EDT 2019

Fix two potential undefined behaviours

Avoid shifting a signed value and avoid passing a NULL to memcpy.

--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -140,7 +140,7 @@
 sinc_set_converter (SRC_PRIVATE *psrc, int src_enum)
 {	SINC_FILTER *filter, temp_filter ;
 	increment_t count ;
-	int bits ;
+	uint32_t bits ;
 
 	/* Quick sanity check. */
 	if (SHIFT_BITS >= sizeof (increment_t) * 8 - 1)
@@ -1158,6 +1158,9 @@
 
 	if (filter->b_real_end >= 0)
 		return 0 ;	/* Should be terminating. Just return. */
+
+	if (data->data_in == NULL)
+		return 0 ;
 
 	if (filter->b_current == 0)
 	{	/* Initial state. Set up zeros at the start of the buffer and