mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 751262 - Guard against leaking memory if NewDirectByteBuffer fails. r=blassey
This commit is contained in:
parent
9d8cae7b2a
commit
3f5caf2fcb
@ -66,7 +66,14 @@ __attribute__ ((visibility("default")))
|
||||
jobject JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_allocateDirectBuffer(JNIEnv *jenv, jclass, jlong size)
|
||||
{
|
||||
return jenv->NewDirectByteBuffer(malloc(size), size);
|
||||
jobject buffer = NULL;
|
||||
void* mem = malloc(size);
|
||||
if (mem) {
|
||||
buffer = jenv->NewDirectByteBuffer(mem, size);
|
||||
if (!buffer)
|
||||
free(mem);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
@ -107,4 +114,4 @@ Java_org_mozilla_gecko_GeckoAppShell_unlockDatabaseFile(JNIEnv *jenv, jclass, js
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user