Skip to content

Commit a2e71d9

Browse files
committed
NewGlobalRef shouldn't throw on null output if input is null
1 parent 13ea409 commit a2e71d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/jni/functions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace jni
131131
{
132132
jobject* obj = Wrap<jobject*>(env.NewGlobalRef(Unwrap(t)));
133133
CheckJavaException(env);
134-
if (!obj)
134+
if (t && !obj)
135135
throw std::bad_alloc();
136136
return UniqueGlobalRef<T>(reinterpret_cast<T*>(obj), GlobalRefDeleter(env));
137137
}

0 commit comments

Comments
 (0)