From: Jiyong Min Date: Wed, 27 Sep 2017 10:36:17 +0000 (+0900) Subject: Modify to free memory encoded to bmp and add to check return value from fread X-Git-Tag: submit/tizen/20170928.093256^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de4abfd703dbfbf7c1b83e551df4a70f016f8f89;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Modify to free memory encoded to bmp and add to check return value from fread (fix coverity issue) Change-Id: Id380453efa6a148e900aba38eff78045ac2c9840 Signed-off-by: Jiyong Min --- diff --git a/bmp/mm_util_bmp.c b/bmp/mm_util_bmp.c index 9d7a628..946b310 100755 --- a/bmp/mm_util_bmp.c +++ b/bmp/mm_util_bmp.c @@ -285,7 +285,7 @@ int mm_util_encode_bmp_to_memory(mm_util_bmp_data *encoded, void **buffer, size_ if (bmp_save2(bmp, buffer, size) == false) { mm_util_error("Saving bmp was failed."); bmp_destroy(bmp); - BMP_SAFE_FREE(buffer); + BMP_SAFE_FREE(*buffer); *size = 0; return MM_UTIL_ERROR_INVALID_OPERATION; } diff --git a/imgp/mm_util_imgp.c b/imgp/mm_util_imgp.c index 086fcc5..82cd5e8 100755 --- a/imgp/mm_util_imgp.c +++ b/imgp/mm_util_imgp.c @@ -894,7 +894,11 @@ gpointer _mm_util_thread_repeate(gpointer data) end_time = g_get_monotonic_time() + 1 * G_TIME_SPAN_SECOND; mm_util_debug("waiting..."); g_mutex_lock(&(handle->thread_mutex)); - g_cond_wait_until(&(handle->thread_cond), &(handle->thread_mutex), end_time); + if (!g_cond_wait_until(&(handle->thread_cond), &(handle->thread_mutex), end_time)) { + mm_util_debug("exit loop"); + g_mutex_unlock(&(handle->thread_mutex)); + break; + } mm_util_debug("<=== get run transform thread signal"); g_mutex_unlock(&(handle->thread_mutex)); @@ -1331,7 +1335,8 @@ int mm_util_create(mm_util_imgp_h *imgp_handle) mm_util_s *handle = calloc(1, sizeof(mm_util_s)); if (!handle) { mm_util_error("[ERROR] - _handle"); - ret = MM_UTIL_ERROR_INVALID_OPERATION; + TTRACE_END(); + return MM_UTIL_ERROR_INVALID_OPERATION; } ret = __mm_util_handle_init(handle); @@ -1339,12 +1344,13 @@ int mm_util_create(mm_util_imgp_h *imgp_handle) mm_util_error("_mm_util_handle_init failed"); IMGP_FREE(handle); TTRACE_END(); - return MM_UTIL_ERROR_INVALID_PARAMETER; + return ret; } ret = __mm_util_create_thread(handle); if (ret != MM_UTIL_ERROR_NONE) { mm_util_error("ERROR - Create thread"); + IMGP_FREE(handle); TTRACE_END(); return ret; } else { diff --git a/imgp/test/mm_util_imgp_testsuite.c b/imgp/test/mm_util_imgp_testsuite.c index be44e20..ef4f84f 100755 --- a/imgp/test/mm_util_imgp_testsuite.c +++ b/imgp/test/mm_util_imgp_testsuite.c @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) goto TEST_FAIL; } - if (fread(src, 1, (int)src_size, fp)) + if (fread(src, 1, (int)src_size, fp) == src_size) mm_util_debug("#Success# fread"); else mm_util_error("#Error# fread"); diff --git a/jpeg/test/mm_util_jpeg_testsuite.c b/jpeg/test/mm_util_jpeg_testsuite.c index 75cf6fc..29aea88 100755 --- a/jpeg/test/mm_util_jpeg_testsuite.c +++ b/jpeg/test/mm_util_jpeg_testsuite.c @@ -72,7 +72,7 @@ static int _read_file(char *file_name, void **data, unsigned int *data_size) fp = NULL; return FALSE; } else { - if (fread(*data, 1, file_size, fp)) { + if (fread(*data, 1, file_size, fp) == (size_t)file_size) { fprintf(stderr, "#Success# fread\n"); } else { fprintf(stderr, "#Error# fread\n"); diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index ef92872..ef1cdc4 100755 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -1,6 +1,6 @@ Name: libmm-utility Summary: Multimedia Framework Utility Library -Version: 0.41 +Version: 0.42 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/png/test/mm_util_png_testsuite.c b/png/test/mm_util_png_testsuite.c index 1a708cc..dc73899 100755 --- a/png/test/mm_util_png_testsuite.c +++ b/png/test/mm_util_png_testsuite.c @@ -67,7 +67,7 @@ static int _read_file(char *file_name, void **data, int *data_size) fp = NULL; return FALSE; } else { - if (fread(*data, 1, file_size, fp)) { + if (fread(*data, 1, file_size, fp) == (size_t)file_size) { fprintf(stderr, "\t#Success# fread\n"); } else { fprintf(stderr, "\t#Error# fread\n");