[easytag/easytag-2-2] Fix memory leak when loading a Speex file



commit 2b5a98c28f1d02d79dc387b30968a1a7d2f2d379
Author: David King <amigadave amigadave com>
Date:   Sun Dec 14 13:54:44 2014 +0000

    Fix memory leak when loading a Speex file

 src/vcedit.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/vcedit.c b/src/vcedit.c
index 182c30d..292e36a 100644
--- a/src/vcedit.c
+++ b/src/vcedit.c
@@ -74,6 +74,12 @@ static void vcedit_clear_internals(vcedit_state *state)
         vorbis_info_clear(state->vi);
         free(state->vi);
     }
+#ifdef ENABLE_SPEEX
+    if (state->si)
+    {
+        speex_header_free (state->si);
+    }
+#endif
 #ifdef ENABLE_OPUS
     if (state->oi)
     {
@@ -379,11 +385,13 @@ vcedit_open(vcedit_state *state, GFile *file, GError **error)
     else
     {
 #ifdef ENABLE_SPEEX
-        // Done after "Ogg test" to avoid to display an error message in function
-        // speex_packet_to_header when the file is not Speex.
-        state->si = malloc(sizeof(SpeexHeader));
-        if((state->si = speex_packet_to_header((char*)(&header_main)->packet,(&header_main)->bytes)))
+        /* Done after "Ogg test" to avoid to display an error message in
+         * function speex_packet_to_header() when the file is not Speex. */
+        if((state->si = speex_packet_to_header ((char*)(&header_main)->packet,
+                                                (&header_main)->bytes)))
+        {
             state->oggtype = VCEDIT_IS_SPEEX;
+        }
 #endif
 #ifdef ENABLE_OPUS
         if (state->oggtype == VCEDIT_IS_UNKNOWN)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]