[glib] Plug a mem leak in data-input-stream test



commit 91e380359604dfabf5c98fab8e317c655d32f98b
Author: Christian Persch <chpe gnome org>
Date:   Fri Sep 3 15:45:48 2010 -0400

    Plug a mem leak in data-input-stream test
    
    ==2415== 165 (72 direct, 93 indirect) bytes in 3 blocks are definitely lost in loss record 373 of 399
    ==2415==    at 0x4005BDC: malloc (vg_replace_malloc.c:195)
    ==2415==    by 0x4057094: g_malloc (gmem.c:134)
    ==2415==    by 0x406F2D6: g_slice_alloc (gslice.c:836)
    ==2415==    by 0x406F31B: g_slice_alloc0 (gslice.c:848)
    ==2415==    by 0x403A8A6: g_error_new_literal (gerror.c:117)
    ==2415==    by 0x403AC31: g_set_error_literal (gerror.c:314)
    ==2415==    by 0x417ED29: read_data (gdatainputstream.c:309)
    ==2415==    by 0x417EE9D: g_data_input_stream_read_byte (gdatainputstream.c:344)
    ==2415==    by 0x8049DEC: test_data_array (data-input-stream.c:263)
    
    Bug #628331.

 gio/tests/data-input-stream.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gio/tests/data-input-stream.c b/gio/tests/data-input-stream.c
index b05241a..dcbcd3d 100644
--- a/gio/tests/data-input-stream.c
+++ b/gio/tests/data-input-stream.c
@@ -296,13 +296,15 @@ test_data_array (GInputStream *stream, GInputStream *base_stream,
           g_assert_not_reached ();
           break;
 	}
-      if ((data) && (! error))  
+      if (!error)
 	g_assert_cmpint (data, ==, TEST_DATA_RETYPE_BUFF(data_type, gint64, ((guchar*)buffer + pos)));
       
       pos += data_size;
     }
   if (pos < len + 1)
     g_assert_no_error (error);
+  if (error)
+    g_error_free (error);
   g_assert_cmpint (pos - data_size, ==, len);
 }
 



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