Fixed a fault strcpy hedgeroid
authorXeli
Fri, 24 Jun 2011 13:19:32 +0200
branchhedgeroid
changeset 5353 37b0fb82e22c
parent 5350 4c100fbfad5f
child 5356 bf058f0a77d6
Fixed a fault strcpy
project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp
--- a/project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp	Fri Jun 24 13:14:03 2011 +0200
+++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp	Fri Jun 24 13:19:32 2011 +0200
@@ -24,12 +24,14 @@
 
     //Get the String array from java
     int argc = env->GetArrayLength(strArray);
-    char* argv[argc];
+    char *argv[argc];
     jstring jstringArgv[argc];
     for(int i = 0; i < argc; i++){
         jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i);  //get the element
+	argv[i] = (char*)malloc(sizeof(char) * env->GetStringLength(jstringArgv[i]));
 	strcpy(argv[i], env->GetStringUTFChars(jstringArgv[i], JNI_FALSE)); //copy it to a mutable location
-        env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]);           //release mem
+	//Don't release memory the JAVA GC will take care of it
+        //env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]);           
     }
     
     /* Run the application code! */