From 8d8d4a99c14a53a03020388766d50cc2032345ac Mon Sep 17 00:00:00 2001 From: Eric Kinzie Date: Sat, 9 Oct 2021 20:35:05 -0400 Subject: [PATCH] fix null pointer dereference in class Claim releaseTimeString can be initialized to null. Check for this case before trying to parse it. --- app/src/main/java/io/lbry/browser/model/Claim.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/model/Claim.java b/app/src/main/java/io/lbry/browser/model/Claim.java index ff7b47c3..e18adbd1 100644 --- a/app/src/main/java/io/lbry/browser/model/Claim.java +++ b/app/src/main/java/io/lbry/browser/model/Claim.java @@ -384,10 +384,12 @@ public class Claim { long feeAmount = searchResultObject.isNull("fee") ? 0 : searchResultObject.getLong("fee"); String releaseTimeString = !searchResultObject.isNull("release_time") ? searchResultObject.getString("release_time") : null; long releaseTime = 0; - try { - releaseTime = Double.valueOf(new SimpleDateFormat(RELEASE_TIME_DATE_FORMAT).parse(releaseTimeString).getTime() / 1000.0).longValue(); - } catch (ParseException ex) { - // pass + if (releaseTimeString != null) { + try { + releaseTime = Double.valueOf(new SimpleDateFormat(RELEASE_TIME_DATE_FORMAT).parse(releaseTimeString).getTime() / 1000.0).longValue(); + } catch (ParseException ex) { + // pass + } } GenericMetadata metadata = (duration > 0 || releaseTime > 0 || feeAmount > 0) ? new StreamMetadata() : new GenericMetadata();