Skip to content

Commit

Permalink
ANDROID: ReleaseStringUTFChars doesn't allow NULL as final arg
Browse files Browse the repository at this point in the history
  • Loading branch information
mgorges committed Nov 9, 2020
1 parent c2585dc commit 7561c9a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions loaders/android/bootstrap.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ static const char* app_code_path = NULL;

void Java_@SYS_PACKAGE_UNDERSCORE@_@SYS_APPNAME@_nativeInstanceInit(JNIEnv* env, jobject thiz, jstring codePath, jstring directoryFiles){
globalObj = (*env)->NewGlobalRef(env,thiz);
app_directory_files = strdup((*env)->GetStringUTFChars(env, directoryFiles, 0));
(*env)->ReleaseStringUTFChars(env, directoryFiles, NULL);
app_directory_files = strdup((*env)->GetStringUTFChars(env, directoryFiles, 0));
(*env)->ReleaseStringUTFChars(env, directoryFiles, app_directory_files);
app_code_path = strdup((*env)->GetStringUTFChars(env, codePath, 0));
(*env)->ReleaseStringUTFChars(env, codePath, NULL);
(*env)->ReleaseStringUTFChars(env, codePath, app_code_path);
}

char* android_getFilesDir() {
Expand Down

5 comments on commit 7561c9a

@0-8-15
Copy link
Contributor

@0-8-15 0-8-15 commented on 7561c9a Nov 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be the case that this change is responsible for android_getFilesDir no longer working after the git pull?

@0-8-15
Copy link
Contributor

@0-8-15 0-8-15 commented on 7561c9a Nov 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking closer: this change does not make any sense to me. Why pass some arbitrary pointer to ReleaseStringUTFChars? those pointers where create by malloc (within strdup). ReleaseStringUTFChars has no business with them.

@mgorges
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULL is not a valid argument - it stops the compilation. These are the appropriate variables that we want the strings to be put into, so I am not sure why this is a problem?

@mgorges
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0-8-15
Copy link
Contributor

@0-8-15 0-8-15 commented on 7561c9a Nov 23, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.