From 9a945c950e8796a4d678a19d4b4591a65946d7ee Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 12 Nov 2020 00:03:57 +0100 Subject: [PATCH] Fix potential NPE when the input stream is closed too soon in the old network API --- .../pandacube/util/network_api/client/ResponseAnalyser.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/fr/pandacube/util/network_api/client/ResponseAnalyser.java b/src/main/java/fr/pandacube/util/network_api/client/ResponseAnalyser.java index 29c5a74..cb50435 100644 --- a/src/main/java/fr/pandacube/util/network_api/client/ResponseAnalyser.java +++ b/src/main/java/fr/pandacube/util/network_api/client/ResponseAnalyser.java @@ -26,10 +26,14 @@ public class ResponseAnalyser { // lecture de la première ligne line = in.readLine(); + if (line == null) + throw new IOException("Not enough data to read first line of response."); good = line.equalsIgnoreCase("OK"); // lecture de la deuxième ligne line = in.readLine(); + if (line == null) + throw new IOException("Not enough data to read second line of response."); int data_size = 0; try {