From 0de91b3ae49a4bdb172cd3318a7e149f8d6973b9 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Tue, 4 Jun 2024 23:11:50 +0200 Subject: [PATCH] Berry `input()` returns empty string and does not crash --- 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 7517f6d26cbf..88c52a8ba20f 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 0c70bf61c55f..db40e153f0ea 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. */