diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-04-24 20:40:52 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-04-24 20:40:52 +0000 |
commit | 9334cd451b299afe46703c59d13297ca48b684a4 (patch) | |
tree | 262a6d7a4f9d1a0162e6d33feca3fe07ff194e0e /src/target | |
parent | 040e25424314b49e35eb158eb88e287c76e50596 (diff) | |
download | openocd_libswd-9334cd451b299afe46703c59d13297ca48b684a4.tar.gz openocd_libswd-9334cd451b299afe46703c59d13297ca48b684a4.tar.bz2 openocd_libswd-9334cd451b299afe46703c59d13297ca48b684a4.tar.xz openocd_libswd-9334cd451b299afe46703c59d13297ca48b684a4.zip |
Close dangling file handle
git-svn-id: svn://svn.berlios.de/openocd/trunk@616 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/image.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/target/image.c b/src/target/image.c index 1eb95672..72a3828c 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -57,15 +57,19 @@ static int autodetect_image_type(image_t *image, char *url) { return retval; } - if ((retval = fileio_read(&fileio, 9, buffer, &read_bytes)) != ERROR_OK) - { - return ERROR_FILEIO_OPERATION_FAILED; - } - if (read_bytes != 9) + retval = fileio_read(&fileio, 9, buffer, &read_bytes); + + if (retval==ERROR_OK) { - return ERROR_FILEIO_OPERATION_FAILED; + if (read_bytes != 9) + { + retval=ERROR_FILEIO_OPERATION_FAILED; + } } fileio_close(&fileio); + + if (retval!=ERROR_OK) + return retval; /* check header against known signatures */ if (strncmp((char*)buffer,ELFMAG,SELFMAG)==0) |