summaryrefslogtreecommitdiff
path: root/camlibs
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2014-06-30 06:38:31 +0000
committerMarcus Meissner <marcus@jet.franken.de>2014-06-30 06:38:31 +0000
commitb8bc29954f32d543c6e5a8e2ab395046faa44396 (patch)
tree4ced6925111dc0f6585be6535f0cd22017c95f95 /camlibs
parent8069d9743871887fc6733347e64f77f446f353a3 (diff)
downloadlibgphoto2-b8bc29954f32d543c6e5a8e2ab395046faa44396.tar.gz
fixed memory leaks in error exits (Coverity)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15044 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs')
-rw-r--r--camlibs/stv0680/library.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/camlibs/stv0680/library.c b/camlibs/stv0680/library.c
index 7aa6eeb08..8b11c4e53 100644
--- a/camlibs/stv0680/library.c
+++ b/camlibs/stv0680/library.c
@@ -258,17 +258,25 @@ int stv0680_get_image(GPPort *port, int image_no, CameraFile *file)
sprintf(header, "P6\n# gPhoto2 stv0680 image\n#flags %x sgain %d sclkdiv %d avgpix %d fine %d coarse %d\n%d %d\n255\n", imghdr.flags, imghdr.sensor_gain, imghdr.sensor_clkdiv, imghdr.avg_pixel_value, fine, coarse , w, h);
gp_file_append(file, header, strlen(header));
- if ((ret=gp_port_read(port, (char *)raw, size))<0)
- return ret;
+ if ((ret=gp_port_read(port, (char *)raw, size))<0) {
+ free (raw);
+ return ret;
+ }
data = malloc(size * 3);
+ if (!data) {
+ free (raw);
+ return GP_ERROR_NO_MEMORY;
+ }
tmpdata1 = malloc(size * 3);
if (!tmpdata1) {
+ free (raw);
free (data);
return GP_ERROR_NO_MEMORY;
}
tmpdata2 = malloc(size * 3);
if (!tmpdata2) {
+ free (raw);
free (data);
free (tmpdata1);
return GP_ERROR_NO_MEMORY;