diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2012-03-23 18:36:21 +0100 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2012-03-23 20:21:52 +0100 |
commit | d84d98943af42ce645ee022207bcf04e747d2d4a (patch) | |
tree | 8f98677ed631cd36b37ed5f88873c251a8010342 | |
parent | 4f1bcb55a40603f2d6bc94c16befd8fa9989cb3b (diff) | |
download | gstreamer-plugins-bad-d84d98943af42ce645ee022207bcf04e747d2d4a.tar.gz |
modplug: memory handling cleanup
Don't leak the CSoundFile. Use define for comment buffer size and ensure it is 0
terminated.
-rw-r--r-- | ext/modplug/gstmodplug.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index 8b42a52bd..346809971 100644 --- a/ext/modplug/gstmodplug.cc +++ b/ext/modplug/gstmodplug.cc @@ -646,7 +646,8 @@ gst_modplug_loop (GstModPlug * modplug) GstEvent *newsegment; GstTagList *tags; gboolean ok; - gchar comment[16384]; + #define COMMENT_SIZE 16384 + gchar comment[COMMENT_SIZE]; ok = gst_modplug_load_song (modplug); gst_buffer_unref (modplug->buffer); @@ -668,7 +669,9 @@ gst_modplug_loop (GstModPlug * modplug) GST_TAG_BEATS_PER_MINUTE, (gdouble) modplug->mSoundFile->GetMusicTempo (), NULL); - if (modplug->mSoundFile->GetSongComments ((gchar *) & comment, 16384, 32)) { + if (modplug->mSoundFile->GetSongComments ((gchar *) & comment, + COMMENT_SIZE, 32)) { + comment[COMMENT_SIZE - 1] = '\0'; gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_COMMENT, comment, NULL); } @@ -777,6 +780,7 @@ gst_modplug_change_state (GstElement * element, GstStateChange transition) } if (modplug->mSoundFile) { modplug->mSoundFile->Destroy (); + delete modplug->mSoundFile; modplug->mSoundFile = NULL; } break; |