]> git.sur5r.net Git - openocd/commitdiff
TARGET: fix segfault in handle_dump_image_command()
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 12 Oct 2010 08:08:35 +0000 (16:08 +0800)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 12 Oct 2010 09:22:26 +0000 (11:22 +0200)
The struct fileio is used after fileio_close().
Move fileio_close() after last usage.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
src/target/target.c

index 82cbbff547340b767c192828c38c4b2d1190090a..3c85502e903a0161e9a804d8b1d61075ff75c755 100644 (file)
@@ -2643,9 +2643,6 @@ COMMAND_HANDLER(handle_dump_image_command)
                address += this_run_size;
        }
 
-       if ((retvaltemp = fileio_close(&fileio)) != ERROR_OK)
-               return retvaltemp;
-
        if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK))
        {
                int filesize;
@@ -2657,6 +2654,9 @@ COMMAND_HANDLER(handle_dump_image_command)
                                duration_elapsed(&bench), duration_kbps(&bench, filesize));
        }
 
+       if ((retvaltemp = fileio_close(&fileio)) != ERROR_OK)
+               return retvaltemp;
+
        return retval;
 }