From aa529eb5a0dd89afdd7c0b500ab26e564d7c8421 Mon Sep 17 00:00:00 2001 From: wadim Date: Thu, 1 Oct 2020 14:36:23 +0200 Subject: [PATCH] Fix getString() freeze on empty responses (#4317) --- libraries/HTTPClient/src/HTTPClient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index e6e448cb..0383c149 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -921,13 +921,16 @@ String HTTPClient::getString(void) { StreamString sstring; - if(_size) { + if(_size > 0) { // try to reserve needed memmory if(!sstring.reserve((_size + 1))) { log_d("not enough memory to reserve a string! need: %d", (_size + 1)); return ""; } } + else { + return ""; + } writeToStream(&sstring); return sstring;