Skip to content

Commit e5d6733

Browse files
committed
fix: callback return void crash
1 parent f703e80 commit e5d6733

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dart_native/android/src/main/jni/dart_native.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,15 @@ extern "C"
441441
if (notifyResult)
442442
{
443443
sem_wait(&sem);
444-
if (strcmp(returnType, "java.lang.String") == 0)
444+
if (returnType == nullptr || strcmp(returnType, "void") == 0)
445+
{
446+
DNDebug("Native callback to Dart return type is void");
447+
}
448+
else if (strcmp(returnType, "java.lang.String") == 0)
445449
{
446450
callbackResult = convertToJavaUtf16(env, (char *)arguments[argumentCount], nullptr, 0);
447451
}
448-
else if (strcmp(returnType, "void") != 0)
452+
else
449453
{
450454
callbackResult = (jobject)arguments[argumentCount];
451455
}

0 commit comments

Comments
 (0)