From 9e168d84d7e172f5f4b6d0497f4f12ad8c63ff28 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Tue, 4 Jun 2024 23:30:01 +0200 Subject: [PATCH] Berry `input()` returns empty string and does not crash (#21565) --- CHANGELOG.md | 1 + lib/libesp32/berry_tasmota/src/be_port.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7517f6d26..88c52a8ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. ### Changed ### Fixed +- Berry `input()` returns empty string and does not crash ### Removed diff --git a/lib/libesp32/berry_tasmota/src/be_port.cpp b/lib/libesp32/berry_tasmota/src/be_port.cpp index 0c70bf61c..db40e153f 100644 --- a/lib/libesp32/berry_tasmota/src/be_port.cpp +++ b/lib/libesp32/berry_tasmota/src/be_port.cpp @@ -216,7 +216,10 @@ extern "C" { BERRY_API char* be_readstring(char *buffer, size_t size) { - return be_fgets(stdin, buffer, (int)size); + if ((size > 0) && (buffer != NULL)) { + *buffer = 0; + } + return buffer; } /* use the standard library implementation file API. */