diff --git a/CHANGELOG.md b/CHANGELOG.md index 44beac208..849b14e17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased * fix: webxdc.selfName uses the name otherwise displayed +* fix potential crash on startup ## v1.58.2 2025-04 diff --git a/src/main/java/com/b44t/messenger/rpc/Rpc.java b/src/main/java/com/b44t/messenger/rpc/Rpc.java index ed6d02b0b..3eb340889 100644 --- a/src/main/java/com/b44t/messenger/rpc/Rpc.java +++ b/src/main/java/com/b44t/messenger/rpc/Rpc.java @@ -30,9 +30,13 @@ public class Rpc { private void processResponse() throws JsonSyntaxException { String jsonResponse = dcJsonrpcInstance.getNextResponse(); - Response response = gson.fromJson(jsonResponse, Response.class); - if (response.id == 0) { // Got JSON-RPC notification/event, ignore + Response response = gson.fromJson(jsonResponse, Response.class); + if (response == null) { + Log.e(TAG, "Error parsing JSON: " + jsonResponse); + return; + } else if (response.id == 0) { + // Got JSON-RPC notification/event, ignore return; } @@ -63,7 +67,7 @@ public class Rpc { while (true) { try { processResponse(); - } catch (JsonSyntaxException e) { + } catch (Exception e) { e.printStackTrace(); } }