Browse Source

charAt is throwing out of bounds, if empty string

AndyScherzinger 6 năm trước cách đây
mục cha
commit
131a8fafcd

+ 1 - 1
src/main/java/com/owncloud/android/datamodel/OCFile.java

@@ -714,7 +714,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
      * @return 'True' if the file is hidden
      */
     public boolean isHidden() {
-        return getFileName().charAt(0) == '.';
+        return getFileName().length() > 0 && getFileName().charAt(0) == '.';
     }
 
     public String getPermissions() {

+ 1 - 1
src/main/java/com/owncloud/android/datastorage/providers/MountCommandStoragePointProvider.java

@@ -62,7 +62,7 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
             if (!line.toLowerCase(Locale.US).contains("asec") && sPattern.matcher(line).matches()) {
                 String parts[] = line.split(" ");
                 for (String path : parts) {
-                    if (path.charAt(0) == '/' && !path.toLowerCase(Locale.US).contains("vold")) {
+                    if (path.length() > 0 && path.charAt(0) == '/' && !path.toLowerCase(Locale.US).contains("vold")) {
                         result.add(path);
                     }
                 }