[rtems commit] rtems-bin2c.c: Fix free() of altered pointer
Joel Sherril
joel at rtems.org
Thu Nov 27 15:29:28 UTC 2014
Module: rtems
Branch: master
Commit: a8b071dbd5d142b924861cf5508e84a828302fb4
Changeset: http://git.rtems.org/rtems/commit/?id=a8b071dbd5d142b924861cf5508e84a828302fb4
Author: Joel Sherrill <joel.sherrill at oarcorp.com>
Date: Thu Nov 27 09:28:42 2014 -0600
rtems-bin2c.c: Fix free() of altered pointer
---
tools/build/rtems-bin2c.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/build/rtems-bin2c.c b/tools/build/rtems-bin2c.c
index fc0381a..391c259 100644
--- a/tools/build/rtems-bin2c.c
+++ b/tools/build/rtems-bin2c.c
@@ -119,8 +119,8 @@ void process(const char *ifname, const char *ofname)
}
/* find basename */
- char *ifbasename = strdup(ifname);
- if ( ifbasename == NULL ) {
+ char *ifbasename_to_free = strdup(ifname);
+ if ( ifbasename_to_free == NULL ) {
fprintf(stderr, "cannot allocate memory\n" );
fclose(ifile);
if ( createC ) { fclose(ocfile); }
@@ -128,7 +128,8 @@ void process(const char *ifname, const char *ofname)
exit(1);
}
- ifbasename = basename(ifbasename);
+ char *ifbasename;
+ ifbasename = basename(ifbasename_to_free);
strcpy(buf, ifbasename);
for (p = buf; *p != '\0'; ++p) {
@@ -252,7 +253,7 @@ void process(const char *ifname, const char *ofname)
fclose(ifile);
if ( createC ) { fclose(ocfile); }
if ( createH ) { fclose(ohfile); }
- free(ifbasename);
+ free(ifbasename_to_free);
}
void usage(void)
More information about the vc
mailing list