Add two missing NULL checks of malloc'd values on Android

* src/android.c (sendDndUri, sendDndText): Verify that allocated
string memory is non-nil before writing to it.
This commit is contained in:
Po Lu 2025-02-15 16:58:18 +08:00
parent 81ca9c75f1
commit 58e4bfe340

View file

@ -2530,6 +2530,11 @@ NATIVE_NAME (sendDndUri) (JNIEnv *env, jobject object,
length = (*env)->GetStringLength (env, string);
buffer = malloc (length * sizeof *buffer);
/* Out of memory. */
if (!buffer)
return 0;
characters = (*env)->GetStringChars (env, string, NULL);
if (!characters)
@ -2567,6 +2572,11 @@ NATIVE_NAME (sendDndText) (JNIEnv *env, jobject object,
length = (*env)->GetStringLength (env, string);
buffer = malloc (length * sizeof *buffer);
/* Out of memory. */
if (!buffer)
return 0;
characters = (*env)->GetStringChars (env, string, NULL);
if (!characters)