hush: small fix for unset -f on NOMMU.
authorroot <root@localhost.localdomain>
Mon, 4 May 2009 10:00:19 +0000 (12:00 +0200)
committerroot <root@localhost.localdomain>
Mon, 4 May 2009 10:00:19 +0000 (12:00 +0200)
Signed-off-by: root <root@localhost.localdomain>
shell/hush.c

index d1f674e9d618a5efbb237023f24f1ea39cef3b50..370e0d71a7155497ed76f850c96db44b4309d8f8 100644 (file)
@@ -2924,13 +2924,13 @@ static void unset_func(const char *name)
        while ((funcp = *funcpp) != NULL) {
                if (strcmp(funcp->name, name) == 0) {
                        *funcpp = funcp->next;
-                       /* funcp is unlinked now, deleting it */
-                       free(funcp->name);
-                       /* Note: if !funcp->body, do not free body_as_string!
-                        * This is a special case of "-F name body" function:
-                        * body_as_string was not malloced! */
+                       /* funcp is unlinked now, deleting it.
+                        * Note: if !funcp->body, the function was created by
+                        * "-F name body", do not free ->body_as_string
+                        * and ->name as they were not malloced. */
                        if (funcp->body) {
                                free_pipe_list(funcp->body);
+                               free(funcp->name);
 # if !BB_MMU
                                free(funcp->body_as_string);
 # endif