prof_tree.c (profile_free_node): Copy child->next to a scratch
authorTheodore Tso <tytso@mit.edu>
Fri, 5 May 1995 03:58:57 +0000 (03:58 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 5 May 1995 03:58:57 +0000 (03:58 +0000)
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
src/util/profile/prof_tree.c
src/util/profile/profile.hin

index aa0d55a5e9fd98e4b2122c59171ba8297d726d17..3bf2b274f8b6b0a7175c93363ac2e9cc6954d50c 100644 (file)
@@ -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  <tytso@dcl>
 
        * prof_parse.c (strip_line): Don't try to strip an empty line.
index c39831955e95aae039dd3c9f8244c57c0c5bc4f9..5cb86c92c93a364ccb7ec661c90d361f2883594f 100644 (file)
@@ -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);
index 3c0d9df95f639a6d14d3dcd1457f398bf5d0c2f7..eca64fbe9561c0e052a99950badf2d4974db017c 100644 (file)
@@ -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,