gobject-introspection r427 - in trunk: . girepository
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r427 - in trunk: . girepository
- Date: Thu, 21 Aug 2008 00:42:23 +0000 (UTC)
Author: walters
Date: Thu Aug 21 00:42:23 2008
New Revision: 427
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=427&view=rev
Log:
2008-08-20 Colin Walters <walters verbum org>
* girepository/girmodule.c (g_ir_module_build_typelib):
Calculate size correctly, avoid use-after-free.
Modified:
trunk/ChangeLog
trunk/girepository/girmodule.c
Modified: trunk/girepository/girmodule.c
==============================================================================
--- trunk/girepository/girmodule.c (original)
+++ trunk/girepository/girmodule.c Thu Aug 21 00:42:23 2008
@@ -64,7 +64,7 @@
g_ir_module_build_typelib (GIrModule *module,
GList *modules)
{
- guchar *typelib;
+ GTypelib *typelib;
gsize length;
gint i;
GList *e;
@@ -102,6 +102,11 @@
size += g_ir_node_get_full_size (node);
}
+ /* Adjust size for strings allocated in header below specially */
+ size += strlen (module->name);
+ if (module->shared_library)
+ size += strlen (module->shared_library);
+
g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n",
size, header_size, dir_size, size - header_size - dir_size);
@@ -201,15 +206,19 @@
}
dump_stats ();
- g_hash_table_destroy (strings);
- g_hash_table_destroy (types);
header->annotations = offset2;
g_message ("reallocating to %d bytes", offset2);
- typelib = g_realloc (data, offset2);
+ data = g_realloc (data, offset2);
+ header = (Header*) data;
length = header->size = offset2;
- return g_typelib_new_from_memory (typelib, length);
+ typelib = g_typelib_new_from_memory (data, length);
+
+ g_hash_table_destroy (strings);
+ g_hash_table_destroy (types);
+
+ return typelib;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]