shithub: sox

Download patch

ref: eabe39a62d599eae8d222ba3d8572f775decdd16
parent: 25982e4ff28ba2d92131db29adcd2b940b2f6bad
author: cbagwell <cbagwell>
date: Sun Jan 9 11:25:35 EST 2011

Fix bug updating WavPack header when closing and a memory leak
when closing.  Patch from David Bryant.

--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,9 @@
   o Fix regression where MP3 handler required libmad headers to be installed.
     (Samuli Suominen) 
   o Add seek support to mp3 handler for speed improvements.  (Pavel Karneliuk)
+  o Fix bug were WavPack header was not updated correctly when closing
+    file.  Fixed libsox memory leak when closing WavPack files.
+    (David Bryant)
 
 Audio device drivers:
 
--- a/src/wavpack.c
+++ b/src/wavpack.c
@@ -158,8 +158,12 @@
     char * buf = lsx_malloc(p->first_block_size);
     lsx_rewind(ft);
     lsx_readchars(ft, buf, p->first_block_size);
-    if (!memcmp(buf, "wvpk", (size_t)4))
+    if (!memcmp(buf, "wvpk", (size_t)4)) {
       WavpackUpdateNumSamples(p->codec, buf);
+      lsx_rewind(ft);
+      lsx_writebuf(ft, buf, p->first_block_size);
+    }
+    free(buf);
   }
   p->codec = WavpackCloseFile(p->codec);
   return SOX_SUCCESS;