Skip to content

Commit b4d4a2c

Browse files
committed
fix: callback return void crash
1 parent fd36ce8 commit b4d4a2c

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
@@ -440,11 +440,15 @@ extern "C"
440440
if (notifyResult)
441441
{
442442
sem_wait(&sem);
443-
if (strcmp(returnType, "java.lang.String") == 0)
443+
if (returnType == nullptr || strcmp(returnType, "void") == 0)
444+
{
445+
DNDebug("Native callback to Dart return type is void");
446+
}
447+
else if (strcmp(returnType, "java.lang.String") == 0)
444448
{
445449
callbackResult = convertToJavaUtf16(env, (char *)arguments[argumentCount], nullptr, 0);
446450
}
447-
else if (strcmp(returnType, "void") != 0)
451+
else
448452
{
449453
callbackResult = (jobject)arguments[argumentCount];
450454
}

0 commit comments

Comments
 (0)