diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2014-01-06 13:40:55 +0000 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2014-01-06 13:40:55 +0000 |
commit | 3d669ba2aeeab6dcd71567276ac8b874e412d334 (patch) | |
tree | e5c32e6d5d6a8ee363445ba9f251bf1e71d72e4c /camlibs/jl2005c | |
parent | de5950c8f2cd9449032fd76b59bb236731eddddb (diff) | |
download | libgphoto2-3d669ba2aeeab6dcd71567276ac8b874e412d334.tar.gz |
check return values, exit on error (Coverity)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14668 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/jl2005c')
-rw-r--r-- | camlibs/jl2005c/library.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/camlibs/jl2005c/library.c b/camlibs/jl2005c/library.c index a635a8524..046a4bfb3 100644 --- a/camlibs/jl2005c/library.c +++ b/camlibs/jl2005c/library.c @@ -239,6 +239,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, } if (!(camera->pl->data_cache)) { GP_DEBUG ("no cache memory allocated!\n"); + free (pic_buffer); return GP_ERROR_NO_MEMORY; } @@ -256,6 +257,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, if (start_of_photo + b > camera->pl->total_data_in_camera) { GP_DEBUG ("Photo runs past end of data. Exiting. \n"); GP_DEBUG ("Block size may be wrong for this camera\n"); + free (pic_buffer); return (GP_ERROR); } /* @@ -352,21 +354,31 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, return GP_OK; #ifdef HAVE_LIBJPEG } else if (type == GP_FILE_TYPE_PREVIEW) { - if (!camera->pl->can_do_capture) + if (!camera->pl->can_do_capture) { + free (pic_buffer); return GP_ERROR_NOT_SUPPORTED; + } outputsize = (pic_buffer[9] & 0xf0) * 192 + 256; GP_DEBUG("pic_buffer[9] is 0x%02x\n", pic_buffer[9]); GP_DEBUG("Thumbnail outputsize = 0x%x = %d\n", outputsize, outputsize); if (outputsize == 256) { GP_DEBUG("Frame %d has no thumbnail.\n", k); + free (pic_buffer); return GP_OK; } pic_output = calloc(outputsize, 1); - if (!pic_output) + if (!pic_output) { + free (pic_buffer); return GP_ERROR_NO_MEMORY; + } outputsize = jl2005bcd_decompress(pic_output, pic_buffer, b + 16, 1); + free (pic_buffer); + if (outputsize < GP_OK) { + free (pic_output); + return outputsize; + } GP_DEBUG("Thumbnail outputsize recalculated is 0x%x = %d\n", outputsize, outputsize); gp_file_set_mime_type(file, GP_MIME_PPM); @@ -379,12 +391,19 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, return GP_ERROR_NO_MEMORY; outputsize = jl2005bcd_decompress(pic_output, pic_buffer, b + 16, 0); + free (pic_buffer); + if (outputsize < GP_OK) { + free (pic_output); + return outputsize; + } gp_file_set_mime_type(file, GP_MIME_PPM); gp_file_set_data_and_size(file, (char *)pic_output, outputsize); #endif - } else + } else { + free (pic_buffer); return GP_ERROR_NOT_SUPPORTED; + } return GP_OK; } |