Fix management of ParseContext.includes_modules (#560419)
authorOwen Taylor <otaylor@src.gnome.org>
Wed, 12 Nov 2008 17:17:08 +0000 (17:17 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 12 Nov 2008 17:17:08 +0000 (17:17 +0000)
Fix some trivial bugs in managing the list of include modules.
(Add to module's list twice, not initialized to NULL, not freed.)

svn path=/trunk/; revision=905

ChangeLog
girepository/girparser.c

index 271fde5..1e4b099 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-12  Owen Taylor  <otaylor@redhat.com>
+
+       Fix management of ParseContext.includes_modules (#560419)
+
+       * girepository/girparser.c: Fix some trivial bugs in managing the
+       list of include modules. (Add to module's list twice, not
+       initialized to NULL, not freed.)
+
 2008-11-12  Owen Taylor  <otaylor@redhat.com>
 
        Keep aliases and disguised_structures local to each module (#560419)
index fcd9dad..198d78b 100644 (file)
@@ -2479,9 +2479,11 @@ start_element_handler (GMarkupParseContext *context,
              for (l = ctx->include_modules; l; l = l->next)
                g_ir_module_add_include_module (ctx->current_module, l->data);
 
+             g_list_free (ctx->include_modules);
+             ctx->include_modules = NULL;
+
              ctx->modules = g_list_append (ctx->modules, ctx->current_module);
              ctx->current_module->dependencies = ctx->dependencies;
-             ctx->current_module->include_modules = g_list_copy (ctx->include_modules);
 
              state_switch (ctx, STATE_NAMESPACE);
              goto out;
@@ -3028,6 +3030,7 @@ g_ir_parser_parse_string (GIrParser           *parser,
   ctx.parser = parser;
   ctx.state = STATE_START;
   ctx.namespace = namespace;
+  ctx.include_modules = NULL;
   ctx.aliases = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
   ctx.disguised_structures = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
   ctx.type_depth = 0;
@@ -3055,12 +3058,14 @@ g_ir_parser_parse_string (GIrParser           *parser,
 
   if (ctx.modules == NULL)
     {
-      /* If we have a module, then ownership is transferred to the module */
-
+      /* An error occurred before we created a module, so we haven't
+       * transferred ownership of these hash tables to the module.
+       */
       if (ctx.aliases != NULL)
        g_hash_table_destroy (ctx.aliases);
       if (ctx.disguised_structures != NULL)
        g_hash_table_destroy (ctx.disguised_structures);
+      g_list_free (ctx.include_modules);
     }
   
   g_markup_parse_context_free (context);