This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 0304721c85146b611c8a3d068de85f147e4e5410
Author: Alan C. Assis <[email protected]>
AuthorDate: Sun Jul 19 20:06:51 2026 +0000

    readline: Don't assert on a zero-length RL_WRITE
    
    Then readline_write() was called with buflen == 0 it was causing a
    debug assertion. Now it returns early for instead of asserting.
    
    Signed-off-by: Alan C. Assis <[email protected]>
---
 system/readline/readline_fd.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/system/readline/readline_fd.c b/system/readline/readline_fd.c
index 2a37d2335..39b7c7898 100644
--- a/system/readline/readline_fd.c
+++ b/system/readline/readline_fd.c
@@ -157,7 +157,21 @@ static void readline_write(FAR struct rl_common_s *vtbl,
                            FAR const char *buffer, size_t buflen)
 {
   FAR struct readline_s *priv = (FAR struct readline_s *)vtbl;
-  DEBUGASSERT(priv && buffer && buflen > 0);
+  DEBUGASSERT(priv && buffer);
+
+  /* Several full-line-redraw paths in readline_common.c (Home, End,
+   * Ctrl+A, Ctrl+U, Ctrl+Left/Right, ...) call RL_WRITE(vtbl, buf, nch)
+   * unconditionally after repositioning the cursor, and 'nch' -- the
+   * number of characters currently in the line -- can legitimately be
+   * 0 (e.g. pressing Home on an empty prompt, or Ctrl+U clearing the
+   * line back to empty).  Writing zero bytes is a valid no-op; it must
+   * not be treated as a caller error.
+   */
+
+  if (buflen == 0)
+    {
+      return;
+    }
 
   /* If outfd is a invalid fd, return directly. */
 

Reply via email to