]> git.sur5r.net Git - openocd/commitdiff
gdb server: do not free tdesc_filename early
authorSpencer Oliver <spen@spen-soft.co.uk>
Fri, 16 Aug 2013 14:37:32 +0000 (15:37 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Thu, 29 Aug 2013 13:02:42 +0000 (13:02 +0000)
Issue caught by clang.

Change-Id: I4fb331574512140b36e56b3b7ab7e8bdad5e013d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1554
Tested-by: jenkins
src/server/gdb_server.c

index 48015abcda1f8e4e65aace51151808f66bd9b911..ab7d40d796acf89a0855cf744cfd3b80023778cd 100644 (file)
@@ -2936,16 +2936,16 @@ COMMAND_HANDLER(handle_gdb_save_tdesc_command)
 
        int retval = fileio_open(&fileio, tdesc_filename, FILEIO_WRITE, FILEIO_TEXT);
 
-       free(tdesc_filename);
-
        if (retval != ERROR_OK) {
                LOG_WARNING("Can't open %s for writing", tdesc_filename);
+               free(tdesc_filename);
                return ERROR_FAIL;
        }
 
        retval = fileio_write(&fileio, tdesc_length, tdesc, &size_written);
 
        fileio_close(&fileio);
+       free(tdesc_filename);
 
        if (retval != ERROR_OK) {
                LOG_WARNING("Error while writing the tdesc file");