summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Galvan <martin.galvan@tallertechnologies.com>2015-09-02 16:54:23 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2015-09-03 12:33:25 -0500
commit9147a825d614cab252a22e8d8a18316180dd0ccb (patch)
treea7260b96984ecfe2516cf072afaab37e4c9c2794
parentcpukit/libnetworking/rtems/rtems_dhcp.c: Fix leak on realloc failure for dhcp... (diff)
downloadrtems-9147a825d614cab252a22e8d8a18316180dd0ccb.tar.bz2
tools/cpu/nios2/ptf.c: Fix leak of memory pointed to by new_prefix
Updates #2405.
-rw-r--r--tools/cpu/nios2/ptf.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/cpu/nios2/ptf.c b/tools/cpu/nios2/ptf.c
index 7a31c11632..07d6183a44 100644
--- a/tools/cpu/nios2/ptf.c
+++ b/tools/cpu/nios2/ptf.c
@@ -567,17 +567,21 @@ void ptf_printf(FILE *s, struct ptf *tree, char *prefix)
new_prefix_len += strlen(leaf->value) + 1;
};
new_prefix = (char *)malloc(new_prefix_len);
- strcpy(new_prefix, prefix);
- strcat(new_prefix, leaf->name);
- if(leaf->value != NULL && leaf->value[0] != 0)
+ if (new_prefix != NULL)
{
- strcat(new_prefix, ":");
- strcat(new_prefix, leaf->value);
- };
- strcat(new_prefix, "/");
- fputs(new_prefix, s);
- fputs("\n", s);
- ptf_printf(s, leaf->sub, new_prefix);
+ strcpy(new_prefix, prefix);
+ strcat(new_prefix, leaf->name);
+ if(leaf->value != NULL && leaf->value[0] != 0)
+ {
+ strcat(new_prefix, ":");
+ strcat(new_prefix, leaf->value);
+ };
+ strcat(new_prefix, "/");
+ fputs(new_prefix, s);
+ fputs("\n", s);
+ ptf_printf(s, leaf->sub, new_prefix);
+ free(new_prefix);
+ }
break;
};