Blob Blame History Raw
diff -up libsndfile-1.0.28/src/common.c.vafix libsndfile-1.0.28/src/common.c
--- libsndfile-1.0.28/src/common.c.vafix	2018-10-15 14:31:59.805758665 +0200
+++ libsndfile-1.0.28/src/common.c	2018-10-15 14:34:48.978445310 +0200
@@ -561,7 +561,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 	while ((c = *format++))
 	{
 		if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
+		{
+			va_end (argptr) ;
 			return count ;
+			} ;
 
 		switch (c)
 		{	case ' ' : /* Do nothing. Just used to space out format string. */
@@ -677,7 +680,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					size = strlen (strptr) + 1 ;
 
 					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 
 					if (psf->rwf_endian == SF_ENDIAN_BIG)
 						header_put_be_int (psf, size + (size & 1)) ;
@@ -698,7 +704,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					strptr = va_arg (argptr, char *) ;
 					size = strlen (strptr) ;
 					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 					if (psf->rwf_endian == SF_ENDIAN_BIG)
 						header_put_be_int (psf, size) ;
 					else
@@ -718,7 +727,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					size = (size > 254) ? 254 : size ;
 
 					if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 
 					header_put_byte (psf, size) ;
 					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
@@ -731,7 +743,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					size	= va_arg (argptr, size_t) ;
 
 					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 
 					memcpy (&(psf->header.ptr [psf->header.indx]), bindata, size) ;
 					psf->header.indx += size ;
@@ -742,7 +757,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					size = va_arg (argptr, size_t) ;
 
 					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 
 					count += size ;
 					while (size)
@@ -763,7 +781,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					size = va_arg (argptr, size_t) ;
 
 					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 
 					psf->header.indx += size ;
 					count += size ;
@@ -773,7 +794,10 @@ psf_binheader_writef (SF_PRIVATE *psf, c
 					size = va_arg (argptr, size_t) ;
 
 					if ((sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, size))
+					{
+						va_end (argptr) ;
 						return count ;
+						} ;
 
 					psf->header.indx = size ;
 					break ;
@@ -960,7 +984,10 @@ psf_binheader_readf (SF_PRIVATE *psf, ch
 	while ((c = *format++))
 	{
 		if (psf->header.indx + 16 >= psf->header.len && psf_bump_header_allocation (psf, 16))
+		{
+			va_end (argptr) ;
 			return count ;
+			} ;
 
 		switch (c)
 		{	case 'e' : /* All conversions are now from LE to host. */
@@ -1087,7 +1114,10 @@ psf_binheader_readf (SF_PRIVATE *psf, ch
 					memset (charptr, 0, count) ;
 
 					if (psf->header.indx + count >= psf->header.len && psf_bump_header_allocation (psf, count))
-						return 0 ;
+					{
+						va_end (argptr) ;
+						return count ;
+						} ;
 
 					byte_count += header_gets (psf, charptr, count) ;
 					break ;