changeset 2659:3a14d7fd4b99

Android: Catch NumberFormatException in isDWResource(). This prevents a crash on non-numeric image assets.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 24 Sep 2021 21:50:17 +0000
parents ad6fc7f1a9af
children 650f8b062317
files android/DWindows.kt
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Fri Sep 24 13:57:16 2021 +0000
+++ b/android/DWindows.kt	Fri Sep 24 21:50:17 2021 +0000
@@ -810,17 +810,18 @@
         for (ext in DWImageExts) {
             if (ext.isNotEmpty() && filename.endsWith(ext)) {
                 val filebody: String = filename.substring(7, length - ext.length)
-                if (filebody.toInt() > 0) {
-                    return true
+                try {
+                    if (filebody.toInt() > 0) {
+                        return true
+                    }
+                } catch(e: NumberFormatException) {
                 }
             }
         }
         return false
     }
 
-    /**
-     * extracts assets/ in the APK to the application cache directory
-     */
+    // Extracts assets/ in the APK to the application cache directory
     private fun extractAssets() {
         var zipFile: ZipFile? = null
         val targetDir = cacheDir