mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 11:27:42 +08:00
tools/cpu/nios2/ptf.c: Fix leak of memory pointed to by new_prefix
Updates #2405.
This commit is contained in:
committed by
Joel Sherrill
parent
c83bad2fc4
commit
9147a825d6
+14
-10
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user