]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[command-parser] free list data in destructors
authorRay Strode <rstrode@redhat.com>
Thu, 6 Aug 2009 02:26:40 +0000 (22:26 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 6 Aug 2009 02:26:40 +0000 (22:26 -0400)
The command and option lists were getting freed, but the
actual commands and options weren't.

src/libply/ply-command-parser.c

index fd77fbfae18b4483231ce5e39d807ab44cf18ebd..3dbc6df9dbbba56d35f40aa842bb2b46bfee01e7 100644 (file)
@@ -124,9 +124,21 @@ ply_command_new (const char *name,
 static void
 ply_command_free (ply_command_t *command)
 {
+  ply_list_node_t *option_node;
+
   if (command == NULL)
     return;
 
+  option_node = ply_list_get_first_node (command->options);
+  while (option_node != NULL)
+    {
+      ply_command_option_t *option;
+
+      option = (ply_command_option_t *) ply_list_node_get_data (option_node);
+      ply_command_option_free (option);
+
+      option_node = ply_list_get_next_node (command->options, option_node);
+    }
   ply_list_free (command->options);
   free (command);
 }
@@ -341,9 +353,21 @@ ply_command_parser_new (const char *name,
 void
 ply_command_parser_free (ply_command_parser_t *command_parser)
 {
+  ply_list_node_t *command_node;
+
   if (command_parser == NULL)
     return;
 
+  command_node = ply_list_get_first_node (command_parser->available_subcommands);
+  while (command_node != NULL)
+    {
+      ply_command_t *command;
+
+      command = (ply_command_t *) ply_list_node_get_data (command_node);
+      ply_command_free (command);
+
+      command_node = ply_list_get_next_node (command_parser->available_subcommands, command_node);
+    }
   ply_list_free (command_parser->available_subcommands);
   ply_list_free (command_parser->read_subcommands);