Apply null pointer of the size for using output path 85/192585/3
authorjiyong.min <jiyong.min@samsung.com>
Wed, 7 Nov 2018 00:36:03 +0000 (09:36 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 13 Nov 2018 22:59:26 +0000 (07:59 +0900)
When the path is used, the output buffer and the size are unused.

Change-Id: Id0360b92fbf23c72f0bffc4429d9620012c4aabc

src/image_util_encode.c

index 168c266..9bd32ff 100755 (executable)
@@ -62,7 +62,7 @@ static void __free_source_buffer(encode_s *handle)
        image_util_fenter();
        image_util_retm_if(handle == NULL || handle->gif_encode_info.sources == NULL, "Invalid handle");
 
-       for(i = 0; i < handle->gif_encode_info.source_count; i++) {
+       for (i = 0; i < handle->gif_encode_info.source_count; i++) {
                IMAGE_UTIL_SAFE_FREE(handle->gif_encode_info.sources[i]);
        }
        IMAGE_UTIL_SAFE_FREE(handle->gif_encode_info.sources);
@@ -320,12 +320,13 @@ int image_util_encode_run(image_util_encode_h handle, unsigned long long *size)
        encode_s *_handle = (encode_s *) handle;
 
        image_util_retvm_if(_handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
-       image_util_retvm_if(size == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+       image_util_retvm_if(_handle->dst_buffer != NULL && size == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
        err = _image_util_encode_internal(_handle);
        image_util_retvm_if((err != IMAGE_UTIL_ERROR_NONE), err, "_image_util_encode_internal failed");
 
-       *size = _handle->dst_size;
+       if (size)
+               *size = _handle->dst_size;
 
        return err;
 }