Fixed bug 3932 - Android, GetDisplayDPI release local reference

Sylvain

When writing JNI code, one has to make sure all local references are released otherwise the app end up crashing.
This commit is contained in:
Sam Lantinga 2017-11-01 17:30:02 -07:00
parent a7d2d12c64
commit 9192c93e90

View File

@ -1065,9 +1065,19 @@ int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi)
float nativeYdpi = (*env)->GetFloatField(env, jDisplayObj, fidYdpi);
int nativeDdpi = (*env)->GetIntField(env, jDisplayObj, fidDdpi);
*ddpi = (float)nativeDdpi;
*xdpi = nativeXdpi;
*ydpi = nativeYdpi;
(*env)->DeleteLocalRef(env, jDisplayObj);
(*env)->DeleteLocalRef(env, jDisplayClass);
if (ddpi) {
*ddpi = (float)nativeDdpi;
}
if (xdpi) {
*xdpi = nativeXdpi;
}
if (ydpi) {
*ydpi = nativeYdpi;
}
return 0;
}