From 7a13d4bcdb96ebc2ea84cc689937cf37d037362a Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Tue, 25 Nov 2014 14:37:12 +0000 Subject: fix nullptr check git-svn-id: http://svn.miranda-ng.org/main/trunk@11061 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'plugins/AdvaImg') diff --git a/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp b/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp index b3bc9f27f3..1e0237d115 100644 --- a/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp +++ b/plugins/AdvaImg/src/FreeImage/PluginJPEG.cpp @@ -959,6 +959,9 @@ jpeg_write_exif_profile_raw(j_compress_ptr cinfo, FIBITMAP *dib) { if(tag_exif) { const BYTE *tag_value = (BYTE*)FreeImage_GetTagValue(tag_exif); + + if (NULL == tag_value) + return FALSE; // verify the identifying string if(memcmp(exif_signature, tag_value, sizeof(exif_signature)) != 0) { @@ -966,23 +969,21 @@ jpeg_write_exif_profile_raw(j_compress_ptr cinfo, FIBITMAP *dib) { return FALSE; } - if(NULL != tag_value) { - DWORD tag_length = FreeImage_GetTagLength(tag_exif); + DWORD tag_length = FreeImage_GetTagLength(tag_exif); - BYTE *profile = (BYTE*)malloc(tag_length * sizeof(BYTE)); - if(profile == NULL) return FALSE; + BYTE *profile = (BYTE*)malloc(tag_length * sizeof(BYTE)); + if(profile == NULL) return FALSE; - for(DWORD i = 0; i < tag_length; i += 65504L) { - unsigned length = MIN((long)(tag_length - i), 65504L); - - memcpy(profile, tag_value + i, length); - jpeg_write_marker(cinfo, EXIF_MARKER, profile, length); - } + for(DWORD i = 0; i < tag_length; i += 65504L) { + unsigned length = MIN((long)(tag_length - i), 65504L); + + memcpy(profile, tag_value + i, length); + jpeg_write_marker(cinfo, EXIF_MARKER, profile, length); + } - free(profile); + free(profile); - return TRUE; - } + return TRUE; } return FALSE; -- cgit v1.2.3