[Android] Fix PathOperation crash

Nicolas Pomepuy git at videolan.org
Tue Oct 6 10:58:46 CEST 2020


vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Sep 29 14:44:25 2020 +0200| [763023be04004afc6b37f02260ed2419e68db3e2] | committer: Nicolas Pomepuy

Fix PathOperation crash

(cherry picked from commit cb3faedd2eb8d4145a6170122f4d95f3c126bad5)

> https://code.videolan.org/videolan/vlc-android/commit/763023be04004afc6b37f02260ed2419e68db3e2
---

 .../src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt
index 3ee1e97d1..c0ef12b64 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt
@@ -43,7 +43,7 @@ class PathOperationDelegate : IPathOperationDelegate {
      */
     override fun appendPathToUri(path: String, uri: Uri.Builder) {
         var newPath = path
-        for (i in 0..storages.size()) if (storages.valueAt(i) == newPath) newPath = storages.keyAt(i)
+        for (i in 0 until storages.size()) if (storages.valueAt(i) == newPath) newPath = storages.keyAt(i)
         newPath.split('/').forEach {
             uri.appendPath(it)
         }
@@ -57,7 +57,7 @@ class PathOperationDelegate : IPathOperationDelegate {
      */
     override fun replaceStoragePath(path: String): String {
         try {
-            if (storages.size() > 0) for (i in 0..storages.size()) if (path.startsWith(storages.keyAt(i))) return path.replace(storages.keyAt(i), storages.valueAt(i))
+            if (storages.size() > 0) for (i in 0 until storages.size()) if (path.startsWith(storages.keyAt(i))) return path.replace(storages.keyAt(i), storages.valueAt(i))
         } catch (e: IllegalStateException) {
         }
         return path



More information about the Android mailing list