Fix wrong api call mv_engine_config_get_string_attribute sandbox/k.son/bug-memory
authorKwanghoon Son <k.son@samsung.com>
Wed, 19 Feb 2020 00:36:01 +0000 (09:36 +0900)
committerKwanghoon Son <k.son@samsung.com>
Wed, 19 Feb 2020 00:36:01 +0000 (09:36 +0900)
Problem
print crack string value.

API mv_engine_config_get_string_attribute is designed to get pointer
parameter(malloc inside). Change to pointer and free after print value.

Change-Id: I180612a0f151151fab6dd88de43ccbcddf053ccd
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
test/testsuites/barcode/barcode_test_suite.c

index bd7a7c7f0fcd590d15ba1fe54c60a73f40068d48..7a3c4c085e1475a2c0f43b52580c8d8d41b1383d 100644 (file)
@@ -229,7 +229,7 @@ bool _mv_engine_config_supported_attribute(mv_config_attribute_type_e attribute_
        int int_value = 0;
        double double_value = 0.0;
        bool bool_value = false;
-       char str_value[1024];
+       char *str_value = NULL;
        switch (attribute_type) {
        case MV_ENGINE_CONFIG_ATTR_TYPE_DOUBLE:
                if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
@@ -274,6 +274,10 @@ bool _mv_engine_config_supported_attribute(mv_config_attribute_type_e attribute_
                }
                printf("Default string attribute %s was set to %s in engine\n",
                                attribute_name, str_value);
+               if (str_value != NULL) {
+                       free(str_value);
+                       str_value = NULL;
+               }
                break;
        default:
                printf("Not supported attribute type\n");