hdt: NULLify autocomplete_tail on destroy
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Mon, 30 Mar 2009 01:18:23 +0000 (18:18 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Mon, 30 Mar 2009 01:18:23 +0000 (18:18 -0700)
Impact: Fix memory corruption

autocomplete_tail needs to be NULLed when freeing the list of
autocomplete tokens or autocomplete_add_token_to_list can get really
confused when starting a new list.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
com32/hdt/hdt-cli.c

index c6d94db..9e46681 100644 (file)
@@ -102,6 +102,7 @@ static void autocomplete_destroy_list()
                autocomplete_head = tmp;
        }
        autocomplete_backlog = 0;
+       autocomplete_tail = NULL;
        autocomplete_last_seen = NULL;
 }
 
@@ -844,9 +845,8 @@ void start_cli_mode(struct s_hardware *hardware)
 
                                /* Cycle through the list */
                                autocomplete_last_seen = autocomplete_last_seen->next;
-                               if (autocomplete_last_seen == NULL) {
+                               if (autocomplete_last_seen == NULL)
                                        autocomplete_last_seen = autocomplete_head;
-                               }
                        } else {
                                more_printf("\n");
                                autocomplete(skipspace(hdt_cli.input));