If OwnString is handled in a type mapper (instead of being NativeMapped), calling this strstr() method will crash due to the return type (arguments work, return types not):
class Test {
static {
Native.register(NativeLibrary.getInstance(C_LIBRARY_NAME, mapWithOwnTypeMapper));
}
private static native OwnString strstr(OwnString haystack, OwnString needle);
}
Here the fix (the result is created but never used/assigned):
diff --git a/native/dispatch.c b/native/dispatch.c
index 71fd083..fc17dd7 100644
--- a/native/dispatch.c
+++ b/native/dispatch.c
@@ -1149,6 +1149,9 @@
if (type->type != FFI_TYPE_POINTER) {
extract_value(env, obj, result, type->size, JNI_TRUE);
}
+ else {
+ *(jobject*)result = obj;
+ }
}
}
}
If OwnString is handled in a type mapper (instead of being NativeMapped), calling this strstr() method will crash due to the return type (arguments work, return types not):
class Test { static { Native.register(NativeLibrary.getInstance(C_LIBRARY_NAME, mapWithOwnTypeMapper)); } private static native OwnString strstr(OwnString haystack, OwnString needle); }Here the fix (the result is created but never used/assigned):
diff --git a/native/dispatch.c b/native/dispatch.c index 71fd083..fc17dd7 100644 --- a/native/dispatch.c +++ b/native/dispatch.c @@ -1149,6 +1149,9 @@ if (type->type != FFI_TYPE_POINTER) { extract_value(env, obj, result, type->size, JNI_TRUE); } + else { + *(jobject*)result = obj; + } } } }