Fix PVS warnings 42/140242/2
authorHaejeong Kim <backto.kim@samsung.com>
Mon, 24 Jul 2017 07:51:24 +0000 (16:51 +0900)
committerhj kim <backto.kim@samsung.com>
Mon, 24 Jul 2017 07:51:59 +0000 (07:51 +0000)
Change-Id: Ie7e00af0e0c47c3a7e50233a6544e9df50bdf4ac

src/image_util.c

index 1c20033..c389703 100755 (executable)
@@ -1082,6 +1082,13 @@ int image_util_decode_set_input_path(image_util_decode_h handle, const char *pat
                return IMAGE_UTIL_ERROR_NO_SUCH_FILE;
        }
        src_buffer = (void *)malloc(sizeof(_PNG_HEADER));
+       if (src_buffer == NULL) {
+               image_util_error("malloc fail");
+               fclose(fp);
+               fp = NULL;
+               return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
+       }
+
        if (!fread(src_buffer, 1, sizeof(_PNG_HEADER), fp)) {
                image_util_error("File read failed");
                fclose(fp);
@@ -1878,6 +1885,8 @@ int image_util_encode_set_input_buffer(image_util_encode_h handle, const unsigne
        } else {
                if (_handle->src_buffer == NULL)
                        _handle->src_buffer = (void *)calloc(1, sizeof(void *));
+               image_util_retvm_if(_handle->src_buffer == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "calloc fail");
+
                _handle->src_buffer[_handle->current_buffer_count] = (void *)src_buffer;
        }