diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2007-05-10 06:56:56 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2007-05-10 06:56:56 +0000 |
commit | 9ff0ad91d2766d114ec20645c445ae7369d9e9c0 (patch) | |
tree | 478e05c39ae283fa7102c0013fe32275b788465c /camlibs/gsmart300 | |
parent | 2eff90d4ce6112d3a6e3d6bb9a735721e2f85847 (diff) | |
download | libgphoto2-9ff0ad91d2766d114ec20645c445ae7369d9e9c0.tar.gz |
added missing free()s (CID 44) (CID 45)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@10163 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/gsmart300')
-rw-r--r-- | camlibs/gsmart300/gsmart300.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/camlibs/gsmart300/gsmart300.c b/camlibs/gsmart300/gsmart300.c index 4e2bb287a..2db0e635f 100644 --- a/camlibs/gsmart300/gsmart300.c +++ b/camlibs/gsmart300/gsmart300.c @@ -123,7 +123,7 @@ gsmart300_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, uint8_t *p, *lp_jpg, *start_of_file; uint8_t qIndex, value; uint8_t *mybuf; - int i; + int i, ret; /* NOTE : these varialbes are slightly renamed */ int flash_size, data_size, file_size; @@ -145,13 +145,19 @@ gsmart300_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, if (!mybuf) return GP_ERROR_NO_MEMORY; - CHECK (gsmart300_download_data (lib, __GS300_PIC, g_file->index, - flash_size, mybuf)); + ret = gsmart300_download_data (lib, __GS300_PIC, g_file->index, + flash_size, mybuf); + if (ret < GP_OK) { + free (mybuf); + return ret; + } /* now build a jpeg */ lp_jpg = malloc (file_size); - if (!lp_jpg) + if (!lp_jpg) { + free (mybuf); return GP_ERROR_NO_MEMORY; + } start_of_file = lp_jpg; /* copy the header from the template */ @@ -222,6 +228,7 @@ gsmart300_get_image_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, uint8_t *yuv_p; uint8_t *rgb_p; unsigned char pbm_header[14]; + int ret; p = g_file->fat; @@ -238,16 +245,23 @@ gsmart300_get_image_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, size = 9728; mybuf = malloc (size); - CHECK (gsmart300_download_data (lib, __GS300_THUMB, g_file->index, - size, mybuf)); - + if (!mybuf) + return (GP_ERROR_NO_MEMORY); + ret = gsmart300_download_data (lib, __GS300_THUMB, g_file->index, + size, mybuf); + if (ret < GP_OK) { + free (mybuf); + return ret; + } /* effective size of file */ size = 9600; *len = t_width * t_height * 3 + sizeof (pbm_header); *buf = malloc (*len); - if (!*buf) + if (!*buf) { + free (mybuf); return (GP_ERROR_NO_MEMORY); + } tmp = *buf; snprintf (tmp, sizeof (pbm_header), "%s", pbm_header); @@ -276,7 +290,6 @@ gsmart300_get_image_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, yuv_p += 4; } - free (mybuf); return (GP_OK); } |