From 972f38755a47d9611f4d83a34140840ead57d294 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 19 Aug 2016 02:49:55 +0200 Subject: [PATCH] Fixed possible crash in RestApi (reported on Google Play) --- .../com/nutomic/syncthingandroid/syncthing/RestApi.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index 114f2cab..f8dc2d3e 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -422,7 +422,11 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, n.deviceID = json.getString("deviceID"); n.compression = json.getString("compression"); n.introducer = json.getBoolean("introducer"); - if (includeLocal || !mLocalDeviceId.equals(n.deviceID)) { + // Use null-save check because mLocalDeviceId might not be initialized yet. + // Should be replaced with Object.equals() when that becomes available in Android. + boolean sameId = (mLocalDeviceId == n.deviceID) || + (mLocalDeviceId != null && mLocalDeviceId.equals(n.deviceID)); + if (includeLocal || !sameId) { ret.add(n); } }