Reset fenceFd without calling close on it

Locking the fd takes ownership of it (https://cs.android.com/android/platform/superproject/+/master:frameworks/native/libs/ui/include/ui/Gralloc.h;l=68;drc=916c2d0bd4a6dae3eececb8d0e74f0ff00959816), but Image_setFenceFd closes the fd as well, so it was getting double closed

Bug: 243257933
Change-Id: I04c1dd86c1ff7f99f8954873381a0e5a002b7360
This commit is contained in:
Brian Kim
2022-09-02 08:23:06 +00:00
parent 44c0ac96b9
commit 1165c90081

View File

@@ -1014,7 +1014,7 @@ static void Image_getLockedImage(JNIEnv* env, jobject thiz, LockedImage *image)
status_t res = lockImageFromBuffer(
buffer, GRALLOC_USAGE_SW_WRITE_OFTEN, noCrop, fenceFd, image);
// Clear the fenceFd as it is already consumed by lock call.
Image_setFenceFd(env, thiz, /*fenceFd*/-1);
env->SetIntField(thiz, gSurfaceImageClassInfo.mNativeFenceFd, -1);
if (res != OK) {
jniThrowExceptionFmt(env, "java/lang/RuntimeException",
"lock buffer failed for format 0x%x",