mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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 <acassis@gmail.com>
This commit is contained in:
parent
094b988be3
commit
0304721c85
1 changed files with 15 additions and 1 deletions
|
|
@ -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. */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue