From: Damyan Ivanov Date: Sun, 23 May 2021 14:36:36 +0000 (+0300) Subject: fix crash in version checking code with two-component versions (3.14) X-Git-Tag: v0.19.1~2 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;ds=sidebyside;h=bf578ce91cec133d75ef3057016386cf0306ef6a;hp=426a2bd8f495b5cf802e20248599dc5e08309aaf;p=mobile-ledger.git fix crash in version checking code with two-component versions (3.14) --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java index 2460b2e0..09b0a067 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailModel.java @@ -338,8 +338,9 @@ public class ProfileDetailModel extends ViewModel { if (m.matches()) { int major = Integer.parseInt(Objects.requireNonNull(m.group(1))); int minor = Integer.parseInt(Objects.requireNonNull(m.group(2))); - final boolean hasPatch = m.groupCount() >= 3; - int patch = hasPatch ? Integer.parseInt(Objects.requireNonNull(m.group(3))) : 0; + final String patchText = m.group(3); + final boolean hasPatch = patchText != null; + int patch = hasPatch ? Integer.parseInt(patchText) : 0; return hasPatch ? new HledgerVersion(major, minor, patch) : new HledgerVersion(major, minor);