GVariant: clear memory before releasing it
authorRyan Lortie <desrt@desrt.ca>
Fri, 28 Jan 2011 13:23:11 +0000 (08:23 -0500)
committerRyan Lortie <desrt@desrt.ca>
Fri, 28 Jan 2011 13:25:05 +0000 (08:25 -0500)
Bug #640807 makes a reasonable case for why it's better to have your
program crash outright in the case of memory errors.  With this
modification, GVariant is far more likely to do that in the case that a
GVariant pointer is used shortly after being freed.

glib/gvariant-core.c

index df52d34..d510949 100644 (file)
@@ -629,6 +629,7 @@ g_variant_unref (GVariant *value)
       else
         g_variant_release_children (value);
 
+      memset (value, 0, sizeof (GVariant));
       g_slice_free (GVariant, value);
     }
 }