[libgsf] Plug leaks.



commit 9968820e29d0eac52712d7c38682cbaf988802c4
Author: Morten Welinder <terra gnome org>
Date:   Sat Apr 20 17:11:26 2013 -0400

    Plug leaks.

 ChangeLog              |  2 ++
 NEWS                   |  1 +
 gsf/gsf-infile-msvba.c | 20 +++++++++++---------
 3 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4bedd41..9a8ddfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-04-20  Morten Welinder  <terra gnome org>
 
+       * gsf/gsf-infile-msvba.c (gsf_vba_inflate): Plug multiple leaks.
+
        * gsf/gsf-infile-msole.c (gsf_infile_msole_read): Don't read
        beyond the number of bat blocks we have.  (We can have less blocks
        than expected when the bat chain is found to be circular.)  Don't
diff --git a/NEWS b/NEWS
index 138a2e4..40f828d 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Morten:
        * Add modtime support for GsfOutfileZip, GsfOutfileMSOle.
        * Enhance gsf tool to print modtime and create archives with modtime.
        * Improve handling of broken OLE2 files.
+       * Plug leaks.
 
 --------------------------------------------------------------------------
 libgsf 1.14.26
diff --git a/gsf/gsf-infile-msvba.c b/gsf/gsf-infile-msvba.c
index 5189ed6..ae665d3 100644
--- a/gsf/gsf-infile-msvba.c
+++ b/gsf/gsf-infile-msvba.c
@@ -63,12 +63,8 @@ typedef GsfInfileClass GsfInfileMSVBAClass;
 guint8 *
 gsf_vba_inflate (GsfInput *input, gsf_off_t offset, int *size, gboolean add_null_terminator)
 {
-       guint8  sig;
-       guint8 const *tmp;
+       guint8 sig;
        GByteArray *res;
-       GByteArray *tmpres;
-       GsfInput *chunk;
-       guint16 chunk_hdr;
        gsf_off_t length;
 
        res = g_byte_array_new();
@@ -80,8 +76,13 @@ gsf_vba_inflate (GsfInput *input, gsf_off_t offset, int *size, gboolean add_null
 
        length = gsf_input_size (input);
        while (offset < length) {
+               GsfInput *chunk;
+               guint16 chunk_hdr;
+               GByteArray *tmpres;
+               guint8 const *tmp;
 
-               if (NULL == (tmp = gsf_input_read (input, 2, NULL)))
+               tmp = gsf_input_read (input, 2, NULL);
+               if (!tmp)
                        break;
 
                chunk_hdr = GSF_LE_GET_GUINT16 (tmp);
@@ -101,10 +102,11 @@ gsf_vba_inflate (GsfInput *input, gsf_off_t offset, int *size, gboolean add_null
                                offset += 4094;
                        }
                }
-               tmpres = gsf_msole_inflate (chunk,0);
-               gsf_input_seek (input,offset,G_SEEK_CUR);
+               tmpres = gsf_msole_inflate (chunk, 0);
+               gsf_input_seek (input, offset, G_SEEK_CUR);
                g_byte_array_append (res, tmpres->data, tmpres->len);
-               g_byte_array_free (tmpres, FALSE);
+               g_byte_array_free (tmpres, TRUE);
+               g_object_unref (chunk);
        }
        
        if (res == NULL)


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