From bb62ad5cd2c381623038437ff9b79532ce5e3614 Mon Sep 17 00:00:00 2001 From: hj kim Date: Wed, 22 Apr 2020 16:36:49 +0900 Subject: [PATCH] Use g_strdup() instead of g_strndup() Change-Id: I04b8b5021cea1cd9708aea409071807fb34a8c95 --- src/image_util_decode.c | 5 ++--- src/image_util_encode.c | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/image_util_decode.c b/src/image_util_decode.c index a417b80..e48a44f 100644 --- a/src/image_util_decode.c +++ b/src/image_util_decode.c @@ -158,10 +158,9 @@ int image_util_decode_set_input_path(image_util_decode_h handle, const char *pat } IMAGE_UTIL_SAFE_FREE(image_header); - IMAGE_UTIL_SAFE_G_FREE(_handle->path); - _handle->path = g_strndup(path, strlen(path)); - image_util_retvm_if(_handle->path == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + g_free(_handle->path); + _handle->path = g_strdup(path); IMAGE_UTIL_SAFE_FREE(_handle->src_buffer); diff --git a/src/image_util_encode.c b/src/image_util_encode.c index ef68ee6..645d3f4 100644 --- a/src/image_util_encode.c +++ b/src/image_util_encode.c @@ -261,13 +261,10 @@ int image_util_encode_set_output_path(image_util_encode_h handle, const char *pa image_util_retvm_if(handle == NULL, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); image_util_retvm_if(!IMAGE_UTIL_STRING_VALID(path), IMAGE_UTIL_ERROR_NO_SUCH_FILE, "Invalid path"); - if (_handle->dst_buffer) - _handle->dst_buffer = NULL; - - IMAGE_UTIL_SAFE_FREE(_handle->path); + _handle->dst_buffer = NULL; - _handle->path = g_strndup(path, strlen(path)); - image_util_retvm_if(_handle->path == NULL, IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + g_free(_handle->path); + _handle->path = g_strdup(path); return IMAGE_UTIL_ERROR_NONE; } -- 2.7.4