fixed some memory leaks (Coverity)
diff --git a/src/libmtp.c b/src/libmtp.c
index 85ba17d..1730426 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -1684,6 +1684,7 @@
}
if (devices == NULL || numdevs == 0) {
+ free(devices);
return NULL;
}
@@ -2316,6 +2317,7 @@
/* Assign linked list of devices */
if (devices == NULL || numdevs == 0) {
*device_list = NULL;
+ free(devices);
return LIBMTP_ERROR_NO_DEVICE_ATTACHED;
}
@@ -2588,7 +2590,7 @@
prop++;
}
lasthandle = 0xffffffff;
- params->objects = calloc (sizeof(PTPObject),cnt);
+ params->objects = calloc (cnt, sizeof(PTPObject));
prop = props;
i = -1;
for (j=0;j<nrofprops;j++) {
@@ -2638,7 +2640,7 @@
newprops = realloc(params->objects[i].mtpprops,
(params->objects[i].nrofmtpprops+1)*sizeof(MTPProperties));
} else {
- newprops = calloc(sizeof(MTPProperties),1);
+ newprops = calloc(1,sizeof(MTPProperties));
}
if (!newprops) return 0; /* FIXME: error handling? */
params->objects[i].mtpprops = newprops;