From 42848b7219afc576f0550f5cbe9f6706d72ff6ac Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 5 May 1995 03:58:57 +0000 Subject: [PATCH] prof_tree.c (profile_free_node): Copy child->next to a scratch pointer before freeing the node; otherwise we have to dereference a freed object. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5725 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/ChangeLog | 6 ++++++ src/util/profile/prof_tree.c | 6 ++++-- src/util/profile/profile.hin | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index aa0d55a5e..3bf2b274f 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,9 @@ +Thu May 4 23:57:56 1995 Theodore Y. Ts'o (tytso@dcl) + + * prof_tree.c (profile_free_node): Copy child->next to a scratch + pointer before freeing the node; otherwise we have to + dereference a freed object. + Fri Apr 28 15:54:40 1995 Theodore Y. Ts'o * prof_parse.c (strip_line): Don't try to strip an empty line. diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index c39831955..5cb86c92c 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -45,7 +45,7 @@ struct profile_node { void profile_free_node(node) struct profile_node *node; { - struct profile_node *child; + struct profile_node *child, *next; if (node->magic != PROF_MAGIC_NODE) return; @@ -54,8 +54,10 @@ void profile_free_node(node) free(node->name); if (node->value) free(node->value); - for (child=node->first_child; child; child = child->next) + for (child=node->first_child; child; child = next) { + next = child->next; profile_free_node(child); + } node->magic = 0; free(node); diff --git a/src/util/profile/profile.hin b/src/util/profile/profile.hin index 3c0d9df95..eca64fbe9 100644 --- a/src/util/profile/profile.hin +++ b/src/util/profile/profile.hin @@ -20,7 +20,6 @@ extern void profile_release extern long profile_get_values PROTOTYPE ((profile_t profile, const char **names, char ***ret_values)); - extern long profile_get_string PROTOTYPE((profile_t profile, const char *name, const char *subname, const char *subsubname, const char *def_val, -- 2.26.2