When calling el_line make sure that we call the resizing function

callback because el_line updates the legacy LineInfo structure and
we need to notify that the cached copy of the the buffer has changed.
Of course the resizing function can call el_line itself to update
the buffer, so prevent recursion. Bug found by Peter Rufer at Arista.
This commit is contained in:
christos 2024-05-17 02:59:08 +00:00
parent 70dffce551
commit 5336283700
2 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: el.h,v 1.46 2021/08/15 10:08:41 christos Exp $ */
/* $NetBSD: el.h,v 1.47 2024/05/17 02:59:08 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -58,6 +58,7 @@
#define NARROW_HISTORY 0x040
#define NO_RESET 0x080
#define FIXIO 0x100
#define FROM_ELLINE 0x200
typedef unsigned char el_action_t; /* Index to command array */

View File

@ -1,4 +1,4 @@
/* $NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $ */
/* $NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $");
__RCSID("$NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $");
#endif /* not lint && not SCCSID */
#include <errno.h>
@ -365,6 +365,10 @@ el_line(EditLine *el)
size_t offset;
const wchar_t *p;
if (el->el_flags & FROM_ELLINE)
return info;
el->el_flags |= FROM_ELLINE;
info->buffer = ct_encode_string(winfo->buffer, &el->el_lgcyconv);
offset = 0;
@ -377,6 +381,10 @@ el_line(EditLine *el)
offset += ct_enc_width(*p);
info->lastchar = info->buffer + offset;
if (el->el_chared.c_resizefun)
(*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg);
el->el_flags &= ~FROM_ELLINE;
return info;
}