diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2014-06-30 06:39:48 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2014-06-30 06:39:48 +0000 |
commit | 1ff2f2ddbbd6b95c374e473553d53b4c1141d18d (patch) | |
tree | d90f0a8c34a8545139b9b50d1e26197b288bd08f /camlibs/stv0680 | |
parent | b8bc29954f32d543c6e5a8e2ab395046faa44396 (diff) | |
download | libgphoto2-1ff2f2ddbbd6b95c374e473553d53b4c1141d18d.tar.gz |
fixed memory leaks and checked some mallocs (Coverity)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15045 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/stv0680')
-rw-r--r-- | camlibs/stv0680/library.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/camlibs/stv0680/library.c b/camlibs/stv0680/library.c index 8b11c4e53..0f347faf2 100644 --- a/camlibs/stv0680/library.c +++ b/camlibs/stv0680/library.c @@ -213,12 +213,20 @@ int stv0680_get_image_raw(GPPort *port, int image_no, CameraFile *file) size = (imghdr.size[0] << 24) | (imghdr.size[1] << 16) | (imghdr.size[2]<<8) | imghdr.size[3]; raw = malloc(size); - if ((ret=gp_port_read(port, (char *)raw, size))<0) + if (!raw) + return GP_ERROR_NO_MEMORY; + if ((ret=gp_port_read(port, (char *)raw, size))<0) { + free (raw); return ret; + } sprintf(header, "P6\n# gPhoto2 stv0680 image\n%d %d\n255\n", w, h); gp_file_append(file, header, strlen(header)); data = malloc(size * 3); + if (!data) { + free (raw); + return GP_ERROR_NO_MEMORY; + } gp_bayer_decode(raw,w,h,data,BAYER_TILE_GBRG_INTERLACED); free(raw); gp_file_append(file, (char *)data, size*3); |