shithub: libsamplerate

Download patch

ref: 1fd5bf60d63fff2f027bad067346666d2640ee7d
parent: aa6f7617d9297b9fe90863dcf02e9d0cbcb2daad
author: evpobr <evpobr@gmail.com>
date: Sun Nov 15 06:05:27 EST 2020

Destroy state with SRC_STATE::vt::close

--- a/src/common.h
+++ b/src/common.h
@@ -110,7 +110,7 @@
 	/* State clone. */
 	SRC_STATE		*(*copy) (SRC_STATE *state) ;
 
-	/* State private_data close. */
+	/* State close. */
 	void			(*close) (SRC_STATE *state) ;
 } SRC_STATE_VT ;
 
--- a/src/samplerate.c
+++ b/src/samplerate.c
@@ -74,11 +74,7 @@
 src_delete (SRC_STATE *state)
 {
 	if (state)
-	{
 		state->vt->close (state) ;
-		memset (state, 0, sizeof (SRC_STATE)) ;
-		free (state) ;
-	}
 
 	return NULL ;
 } /* src_state */
--- a/src/src_linear.c
+++ b/src/src_linear.c
@@ -285,11 +285,14 @@
 		if (linear)
 		{
 			if (linear->last_value)
-			{	free (linear->last_value) ;
+			{
+				free (linear->last_value) ;
 				linear->last_value = NULL ;
-				} ;
+			}
 			free (linear) ;
 			linear = NULL ;
 		}
+		free (state) ;
+		state = NULL ;
 	}
 } /* linear_close */
--- a/src/src_sinc.c
+++ b/src/src_sinc.c
@@ -1226,11 +1226,14 @@
 		if (sinc)
 		{
 			if (sinc->buffer)
-			{	free (sinc->buffer) ;
+			{
+				free (sinc->buffer) ;
 				sinc->buffer = NULL ;
-				} ;
+			}
 			free (sinc) ;
 			sinc = NULL ;
 		}
+		free (state) ;
+		state = NULL ;
 	}
 } /* sinc_close */
--- a/src/src_zoh.c
+++ b/src/src_zoh.c
@@ -274,11 +274,14 @@
 		if (zoh)
 		{
 			if (zoh->last_value)
-			{	free (zoh->last_value) ;
+			{
+				free (zoh->last_value) ;
 				zoh->last_value = NULL ;
-				} ;
+			}
 			free (zoh) ;
 			zoh = NULL ;
 		}
+		free (state) ;
+		state = NULL ;
 	}
 } /* zoh_close */