[4.0] Fix crash bug 42/163642/2
authorhuiyu,eun <huiyu.eun@samsung.com>
Tue, 12 Dec 2017 14:19:51 +0000 (23:19 +0900)
committerhuiyu,eun <huiyu.eun@samsung.com>
Tue, 12 Dec 2017 14:23:12 +0000 (23:23 +0900)
The strlen is working on array[0] which is currently uninitialized
– so will return a random length back, and will likely copy > 30 bytes of data.
Instead, it should take the length of temp.

Change-Id: If58e1eaf273918501000877b9977d29166970310

dali-csharp-binder/src/application.cpp

index 7e8ee4e..2c7e1aa 100755 (executable)
@@ -156,8 +156,10 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_1(int jarg1) {
     }
     array[ numStrings ] =  NULL; // we allocated +1 for hold the NULL part
 
-    std::string temp = "dali-csharp-app";
-    array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0';
+    std::string temp = "dali-csharp-app"; 
+    char* copy;
+    asprintf(&copy, "%s", temp.c_str() );
+    array[0] = copy;
 
     arg1 = &argC;
     arg2 = &argV;
@@ -211,8 +213,10 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_2(int jarg1, cha
     }
     array[ numStrings ] =  NULL; // we allocated +1 for hold the NULL part
 
-    std::string temp = "dali-csharp-app";
-    array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0';
+    std::string temp = "dali-csharp-app"; 
+    char* copy;
+    asprintf(&copy, "%s", temp.c_str() );
+    array[0] = copy;
 
     arg1 = &argC;
     arg2 = &argV;
@@ -277,7 +281,9 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_3(int jarg1, cha
     array[ numStrings ] =  NULL; // we allocated +1 for hold the NULL part
 
     std::string temp = "dali-csharp-app";
-    array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0';
+    char* copy;
+    asprintf(&copy, "%s", temp.c_str() );
+    array[0] = copy;
 
     arg1 = &argC;
     arg2 = &argV;