[Fixed Bug] Fixed alloc-dealloc-mismatch (new vs. free) 40/73140/1 accepted/tizen/common/20160609.145218 accepted/tizen/ivi/20160609.091739 accepted/tizen/mobile/20160609.091959 accepted/tizen/tv/20160609.091611 accepted/tizen/wearable/20160609.091714 submit/tizen/20160609.040222
authorTae-Young Chung <ty83.chung@samsung.com>
Tue, 7 Jun 2016 01:13:50 +0000 (10:13 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Tue, 7 Jun 2016 01:13:57 +0000 (10:13 +0900)
[cause]
 - allocate memory using operator new[]
 - deallocate the memory using free()
 - it may cause memory corruption or undefined behaviors

[solve]
 - replace operator new[] with malloc()

Change-Id: Icc844a98fda28556b071e62ad2599bacba441974
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
mv_common/src/mv_common_c.cpp
packaging/capi-media-vision.spec

index 9242a56..51e0dbb 100644 (file)
@@ -22,6 +22,7 @@
 #include <mv_private.h>
 
 #include <string.h>
+#include <stdlib.h>
 #include <media_packet.h>
 
 int mv_create_source_c(
@@ -512,11 +513,11 @@ int mv_engine_config_get_string_attribute_c(
 
        LOGD("Convert string to char*");
        int stringSize = attributeValue.size();
-       (*value) = new char[stringSize + 1];
+       (*value) = (char *)malloc(sizeof(char) * (stringSize + 1));
 
        if (attributeValue.copy(*value, stringSize) != attributeValue.size()) {
                LOGE("Conversion from string to char* failed");
-               delete[] (*value);
+               free(*value);
                (*value) = NULL;
                return MEDIA_VISION_ERROR_INVALID_OPERATION;
        }
index 3f33e5e..c9c241a 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.3.16
+Version:     0.3.17
 Release:     1
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-2.0