From c6829c5d4a6e2fe4b9b6a0268ac3078b8dd1b5e9 Mon Sep 17 00:00:00 2001 From: pyler Date: Sat, 27 Aug 2016 13:49:10 +0200 Subject: [PATCH] Check for array length to prevent OutOfBounds error https://github.com/javiersantos/AppUpdater/issues/33 --- .../javiersantos/appupdater/UtilsLibrary.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/com/github/javiersantos/appupdater/UtilsLibrary.java b/library/src/main/java/com/github/javiersantos/appupdater/UtilsLibrary.java index 8fe9e862..d0d1333d 100644 --- a/library/src/main/java/com/github/javiersantos/appupdater/UtilsLibrary.java +++ b/library/src/main/java/com/github/javiersantos/appupdater/UtilsLibrary.java @@ -188,16 +188,20 @@ private static String getVersion(UpdateFrom updateFrom, Boolean isAvailable, Str switch (updateFrom) { default: String[] splitPlayStore = source.split(Config.PLAY_STORE_TAG_RELEASE); - splitPlayStore = splitPlayStore[1].split("(<)"); - version = splitPlayStore[0].trim(); + if (splitPlayStore.length > 1) { + splitPlayStore = splitPlayStore[1].split("(<)"); + version = splitPlayStore[0].trim(); + } break; case GITHUB: String[] splitGitHub = source.split(Config.GITHUB_TAG_RELEASE); - splitGitHub = splitGitHub[1].split("(\")"); - version = splitGitHub[0].trim(); - if (version.contains("v")) { // Some repo uses vX.X.X - splitGitHub = version.split("(v)"); - version = splitGitHub[1].trim(); + if (splitGitHub.length > 1) { + splitGitHub = splitGitHub[1].split("(\")"); + version = splitGitHub[0].trim(); + if (version.contains("v")) { // Some repo uses vX.X.X + splitGitHub = version.split("(v)"); + version = splitGitHub[1].trim(); + } } break; case AMAZON: