[PATCH] fix sanitizeStringForAlphaCompare crash on empty string

wdv50jkc <[email protected]> Wed, 11 Sep 2024 01:02:31 +0200
Newsgroups gmane.comp.video.videolan.vlc.devel
Message-ID <[email protected]>
Hey all,

I hope this is the right place for this. I tried to understand the code 
of conduct but I probably missed something and I'm sorry for that. My 
VLC on Android crashes regularly due to a broken samba share in my 
network, that ultimately leads to a crash in 
sanitizeStringForAlphaCompare when called on an empty string. This patch 
is my suggestion to fix it, but it is nearly impossible for me to 
properly test. I hope it helps anyways.


Kind Regards

McLP

_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
https://mailman.videolan.org/listinfo/vlc-devel
sanitizeEmptyStringForAlphaCompare.patch (text/x-patch, 801 B)
diff --git a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index 7dd682439..e9be23db6 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -443,7 +443,7 @@ fun <T> Flow<T>.launchWhenStarted(scope: LifecycleCoroutineScope): Job = scope.l
  * @return a string having exactly [nbOfDigits] digits at the start
  */
 fun String?.sanitizeStringForAlphaCompare(nbOfDigits: Int): String? {
-    if (this == null) return null
+    if (this == null || this.isEmpty()) return null
     if (first().isDigit()) return buildString {
         var numberOfPrependingZeros =0
         for (c in this@sanitizeStringForAlphaCompare) {