summaryrefslogtreecommitdiff
path: root/camlibs/toshiba
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2007-05-11 16:46:47 +0000
committerMarcus Meissner <marcus@jet.franken.de>2007-05-11 16:46:47 +0000
commit9b29ab6d21e374c106658006b5c115794d6535a5 (patch)
tree12379968361661ba8792d4d15ddcae512aa2db59 /camlibs/toshiba
parent403e7d29f0f9fcff8d27e4f7ae00806dee1e0498 (diff)
downloadlibgphoto2-9b29ab6d21e374c106658006b5c115794d6535a5.tar.gz
added missing free() on exit paths (CID 60)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@10177 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/toshiba')
-rw-r--r--camlibs/toshiba/pdrm11/pdrm11.c5
-rw-r--r--camlibs/toshiba/pdrm11/pdrm11.h14
2 files changed, 17 insertions, 2 deletions
diff --git a/camlibs/toshiba/pdrm11/pdrm11.c b/camlibs/toshiba/pdrm11/pdrm11.c
index 1e8f533d8..d718cd5ed 100644
--- a/camlibs/toshiba/pdrm11/pdrm11.c
+++ b/camlibs/toshiba/pdrm11/pdrm11.c
@@ -197,9 +197,9 @@ int pdrm11_get_file(CameraFilesystem *fs, const char *filename, CameraFileType t
if(type == GP_FILE_TYPE_PREVIEW) {
- CHECK( gp_port_usb_msg_write(port, 0x01, PDRM11_CMD_GET_THUMB, picNum, NULL, 0) );
+ CHECK_AND_FREE( gp_port_usb_msg_write(port, 0x01, PDRM11_CMD_GET_THUMB, picNum, NULL, 0), image );
} else {
- CHECK( gp_port_usb_msg_write(port, 0x01, PDRM11_CMD_GET_PIC, picNum, NULL, 0) );
+ CHECK_AND_FREE( gp_port_usb_msg_write(port, 0x01, PDRM11_CMD_GET_PIC, picNum, NULL, 0), image );
}
ret = gp_port_read(port, image, size);
@@ -208,6 +208,7 @@ int pdrm11_get_file(CameraFilesystem *fs, const char *filename, CameraFileType t
ret = gp_port_read(port, image, size);
if(ret != size) {
GP_DEBUG("gp_port_read returned %d 0x%x. size: %d 0x%x", ret, ret, size, size);
+ free (image);
return(GP_ERROR_IO_READ);
}
}
diff --git a/camlibs/toshiba/pdrm11/pdrm11.h b/camlibs/toshiba/pdrm11/pdrm11.h
index b9b61832d..b89677f26 100644
--- a/camlibs/toshiba/pdrm11/pdrm11.h
+++ b/camlibs/toshiba/pdrm11/pdrm11.h
@@ -40,6 +40,20 @@
} \
}
+#define CHECK_AND_FREE(result, buf) { \
+ int res; \
+ res = result; \
+ if (res < 0) { \
+ res = result; \
+ if (res < 0) { \
+ GP_DEBUG("%s--%d: %s returned 0x%x", __FILE__, __LINE__, __STRING(result), res); \
+ free (buf); \
+ return res; \
+ } \
+ } \
+}
+
+
#define PDRM11_CMD_INIT1 htole16( 0x1f40 )
#define PDRM11_CMD_INIT2 htole16( 0x1f30 )
#define PDRM11_CMD_GET_PIC htole16( 0x9300 )