[glib] Plug a mem leak in the readwrite test



commit 35e101fa0a96fb03db4f503a4b24f4818ada114f
Author: Christian Persch <chpe gnome org>
Date:   Fri Sep 3 15:35:44 2010 -0400

    Plug a mem leak in the readwrite test
    
    And use g_assert_[no_]error().
    
    ==2392== 49 (24 direct, 25 indirect) bytes in 1 blocks are definitely lost in loss record 451 of 573
    ==2392==    at 0x4005BDC: malloc (vg_replace_malloc.c:195)
    ==2392==    by 0x4057094: g_malloc (gmem.c:134)
    ==2392==    by 0x406F2D6: g_slice_alloc (gslice.c:836)
    ==2392==    by 0x406F31B: g_slice_alloc0 (gslice.c:848)
    ==2392==    by 0x403A8A6: g_error_new_literal (gerror.c:117)
    ==2392==    by 0x403AC31: g_set_error_literal (gerror.c:314)
    ==2392==    by 0x41B7619: g_output_stream_set_pending (goutputstream.c:1198)
    ==2392==    by 0x41B5799: g_output_stream_write (goutputstream.c:210)
    ==2392==    by 0x41B590B: g_output_stream_write_all (goutputstream.c:268)
    ==2392==    by 0x8049B54: verify_iostream (readwrite.c:110)
    
    Bug #628331.

 gio/tests/readwrite.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/readwrite.c b/gio/tests/readwrite.c
index 456e566..5113186 100644
--- a/gio/tests/readwrite.c
+++ b/gio/tests/readwrite.c
@@ -110,12 +110,13 @@ verify_iostream (GFileIOStream *file_iostream)
   res = g_output_stream_write_all (out, new_data, strlen (new_data),
 				   &n_bytes, NULL, &error);
   g_assert (!res);
-  g_assert (error != NULL);
-  g_assert (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED));
+  g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED);
+  g_error_free (error);
 
   error = NULL;
   res = g_io_stream_close (iostream, NULL, &error);
-  g_assert (res && error == NULL);
+  g_assert (res);
+  g_assert_no_error (error);
 
   g_free (modified_data);
 }



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