[Android] fix sanitizeStringForAlphaCompare crashes on empty string

Mc LP git at videolan.org
Mon Sep 23 05:19:28 UTC 2024


vlc-android | branch: master | Mc LP <wdv50jkc at gmail.com> | Fri Sep 20 17:28:24 2024 +0200| [627d045d10b939e9ad3fc9ceb7e1f5def1f9fe3d] | committer: Mc LP

fix sanitizeStringForAlphaCompare crashes on empty string

> https://code.videolan.org/videolan/vlc-android/commit/627d045d10b939e9ad3fc9ceb7e1f5def1f9fe3d
---

 application/vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 7dd6824396..6e38cb4e28 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 (isNullOrEmpty()) return this
     if (first().isDigit()) return buildString {
         var numberOfPrependingZeros =0
         for (c in this at sanitizeStringForAlphaCompare) {



More information about the Android mailing list