From 1e3728a48b377c201d921a43c03139a2947d7f37 Mon Sep 17 00:00:00 2001 From: Tae-Young Chung Date: Fri, 10 Feb 2017 20:48:42 +0900 Subject: [PATCH] Fixed memory leak of testsuites Change-Id: Ic9f660c8acb5bbd622f34011982dc06ceba72448 Signed-off-by: Tae-Young Chung --- packaging/capi-media-vision.spec | 2 +- test/testsuites/barcode/barcode_test_suite.c | 37 ++++++++++++++++++---- test/testsuites/image/image_test_suite.c | 1 + .../surveillance/surveillance_test_suite.c | 7 ++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec index bac4c4f..e19efbe 100644 --- a/packaging/capi-media-vision.spec +++ b/packaging/capi-media-vision.spec @@ -1,7 +1,7 @@ Name: capi-media-vision Summary: Media Vision library for Tizen Native API Version: 0.3.24 -Release: 1 +Release: 2 Group: Multimedia/Framework License: Apache-2.0 and BSD-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/test/testsuites/barcode/barcode_test_suite.c b/test/testsuites/barcode/barcode_test_suite.c index d6ef9de..b2a5f19 100644 --- a/test/testsuites/barcode/barcode_test_suite.c +++ b/test/testsuites/barcode/barcode_test_suite.c @@ -666,6 +666,9 @@ int detect_barcode(barcode_model_s model, mv_rectangle_s roi) if (MEDIA_VISION_ERROR_NONE != err) { printf("ERROR: Errors were occurred during opening the file!!! code: %i\n", err); + if (data_buffer != NULL) + destroy_loaded_buffer(data_buffer); + MEDIA_VISION_FUNCTION_LEAVE(); return err; @@ -677,6 +680,12 @@ int detect_barcode(barcode_model_s model, mv_rectangle_s roi) if (MEDIA_VISION_ERROR_NONE != err) { printf("ERROR: Can't convert to the selected colorspace!!! code: %i\n", err); + if (data_buffer != NULL) + destroy_loaded_buffer(data_buffer); + + if (converted_buffer) + free(converted_buffer); + MEDIA_VISION_FUNCTION_LEAVE(); return err; @@ -684,7 +693,7 @@ int detect_barcode(barcode_model_s model, mv_rectangle_s roi) model.out_buffer_ptr = data_buffer; - mv_engine_config_h mv_engine_config; + mv_engine_config_h mv_engine_config = NULL; err = mv_create_engine_config(&mv_engine_config); if (MEDIA_VISION_ERROR_NONE != err) printf("ERROR: Errors were occurred during creating the media engine config: %i\n", err); @@ -705,6 +714,15 @@ int detect_barcode(barcode_model_s model, mv_rectangle_s roi) if (MEDIA_VISION_ERROR_NONE != err) { printf("ERROR: Errors were occurred during creating the source!!! code: %i\n", err); + if (data_buffer != NULL) + destroy_loaded_buffer(data_buffer); + + if (converted_buffer) + free(converted_buffer); + + if (mv_engine_config) + mv_destroy_engine_config(mv_engine_config); + MEDIA_VISION_FUNCTION_LEAVE(); return err; @@ -715,6 +733,16 @@ int detect_barcode(barcode_model_s model, mv_rectangle_s roi) if (MEDIA_VISION_ERROR_NONE != err) { printf("ERROR: Errors were occurred during filling the source!!! code: %i\n", err); + if (data_buffer != NULL) + destroy_loaded_buffer(data_buffer); + + if (converted_buffer) + free(converted_buffer); + + if (mv_engine_config) + mv_destroy_engine_config(mv_engine_config); + + mv_destroy_source(source); MEDIA_VISION_FUNCTION_LEAVE(); return err; @@ -728,14 +756,9 @@ int detect_barcode(barcode_model_s model, mv_rectangle_s roi) if (data_buffer != NULL) destroy_loaded_buffer(data_buffer); - if (MEDIA_VISION_ERROR_NONE != err) { + if (MEDIA_VISION_ERROR_NONE != err) printf("ERROR: Errors were occurred during barcode detection!!! code: %i\n", err); - MEDIA_VISION_FUNCTION_LEAVE(); - - return err; - } - err = mv_destroy_source(source); if (MEDIA_VISION_ERROR_NONE != err) printf("ERROR: Errors were occurred during destroying the source!!! code: %i\n", err); diff --git a/test/testsuites/image/image_test_suite.c b/test/testsuites/image/image_test_suite.c index 4b54e91..e7fbbf7 100644 --- a/test/testsuites/image/image_test_suite.c +++ b/test/testsuites/image/image_test_suite.c @@ -471,6 +471,7 @@ int recognize_image(const char *path_to_image, printf("\nERROR: Errors were occurred during source destroying;" "code %i\n", err2); } + destroy_recognition_result(&result); MEDIA_VISION_FUNCTION_LEAVE(); return err; } diff --git a/test/testsuites/surveillance/surveillance_test_suite.c b/test/testsuites/surveillance/surveillance_test_suite.c index 6bf6fa2..24721d4 100644 --- a/test/testsuites/surveillance/surveillance_test_suite.c +++ b/test/testsuites/surveillance/surveillance_test_suite.c @@ -567,14 +567,15 @@ void push_source() PRINT_R("Incorrect input! Try again."); error = load_mv_source_from_file(path_to_image, source); + + if (path_to_image != NULL) + free(path_to_image); + if (MEDIA_VISION_ERROR_NONE != error) { PRINT_E("Errors were occurred during source loading, code %i", error); return; } - if (path_to_image != NULL) - free(path_to_image); - int video_stream_id = 0; while (input_int("Input video stream identificator (integer value):", -- 2.7.4