changeset 2985:e5d2c74b1a51

Android: Fixed a big in dw_window_get_text() introduced at some point. Also added a number of safety checks to prevent calling into kotlin with NULL.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 27 Mar 2023 08:46:23 +0000
parents ebb94fc2b19f
children 0c5abc2ad5c5
files android/dw.cpp
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/android/dw.cpp	Mon Mar 27 04:59:32 2023 +0000
+++ b/android/dw.cpp	Mon Mar 27 08:46:23 2023 +0000
@@ -5229,7 +5229,7 @@
     JNIEnv *env;
     int retval = DW_ERROR_GENERAL;
 
-    if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    if(handle && string && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
     {
         // Construct a String
         jstring jstr = env->NewStringUTF(string);
@@ -5261,7 +5261,7 @@
     JNIEnv *env;
     int retval = DW_ERROR_GENERAL;
 
-    if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    if(handle && url && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
     {
         // Construct a String
         jstring jstr = env->NewStringUTF(url);
@@ -5294,7 +5294,7 @@
     JNIEnv *env;
     int retval = DW_ERROR_GENERAL;
 
-    if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    if(handle && script && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
     {
         // Construct a String
         jstring jstr = env->NewStringUTF(script);
@@ -6190,11 +6190,11 @@
 char * API dw_window_get_text(HWND handle)
 {
     JNIEnv *env;
+    char *retval = nullptr;
 
     if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
     {
         const char *utf8 = nullptr;
-        char *retval = nullptr;
 
         // First get the class that contains the method you need to call
         jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
@@ -6212,7 +6212,7 @@
             env->ReleaseStringUTFChars(result, utf8);
         }
     }
-    return nullptr;
+    return retval;
 }
 
 /*