[glib] resources: Init refcount to 1



commit 877fe6fb524df8478c963342b7948aa3aa55f25e
Author: Christian Persch <chpe gnome org>
Date:   Sun Feb 5 16:37:36 2012 +0100

    resources: Init refcount to 1
    
    This bug was exposed by fixing the following leak in the resources test:
    
    ==29204== 11,456 (84 direct, 11,372 indirect) bytes in 1 blocks are definitely lost in loss record 859 of 861
    ==29204==    at 0x402AD89: malloc (vg_replace_malloc.c:236)
    ==29204==    by 0x4084724: standard_malloc (gmem.c:85)
    ==29204==    by 0x40847C7: g_malloc (gmem.c:159)
    ==29204==    by 0x409B1E1: g_slice_alloc (gslice.c:1003)
    ==29204==    by 0x409B227: g_slice_alloc0 (gslice.c:1029)
    ==29204==    by 0x41936CF: g_type_create_instance (gtype.c:1872)
    ==29204==    by 0x417CCC9: g_object_constructor (gobject.c:1839)
    ==29204==    by 0x417C6F4: g_object_newv (gobject.c:1703)
    ==29204==    by 0x417CC5A: g_object_new_valist (gobject.c:1820)
    ==29204==    by 0x417C1DB: g_object_new (gobject.c:1535)
    ==29204==    by 0x41E5E29: g_converter_input_stream_new (gconverterinputstream.c:204)
    ==29204==    by 0x4228D38: g_resource_open_stream (gresource.c:363)

 gio/gresource.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/gio/gresource.c b/gio/gresource.c
index c6175fe..338a2d2 100644
--- a/gio/gresource.c
+++ b/gio/gresource.c
@@ -251,6 +251,7 @@ g_resource_load (const gchar *filename,
     return NULL;
 
   resource = g_new0 (GResource, 1);
+  resource->ref_count = 1;
   resource->table = table;
 
   return resource;



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