From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 199223858C54; Tue, 23 May 2023 11:50:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 199223858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684842620; bh=CPKx8J+QLQHJJ8GV8qf+dRvcVxjHFME4sX00WqNLMS0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nUHS0hyHxuHUGLEUVkSxlbsM7n2gzNN2bHXMIVOPQVOvjO4ZgqJ22XZHmu0HxSGTd GPcLEQVEgKn2OzgjgKnp3vCTsg7UJAJ+ZlVfqRN35/1lyitAKELkWxhKUQRsYztAdo xiulXTeG/LO8evPlsbp5kt998C112paEReZcp3mk= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug tui/30056] double free when using reverse-search for a previous command and Ctrl-C Date: Tue, 23 May 2023 11:50:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tui X-Bugzilla-Version: 12.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30056 --- Comment #4 from Tom de Vries --- Alternatively, we can regard this as a multibyte problem: ... diff --git a/readline/readline/mbutil.c b/readline/readline/mbutil.c index dc62b4cc24d..7da3ff17bb5 100644 --- a/readline/readline/mbutil.c +++ b/readline/readline/mbutil.c @@ -363,7 +363,7 @@ _rl_get_char_len (char *src, mbstate_t *ps) /* Look at no more than MB_CUR_MAX characters */ l =3D (size_t)strlen (src); - if (_rl_utf8locale && l > 0 && UTF8_SINGLEBYTE(*src)) + if (_rl_utf8locale && l >=3D 0 && UTF8_SINGLEBYTE(*src)) tmp =3D (*src !=3D 0) ? 1 : 0; else { ... For "right arrow", tui_getc returns 0 and expects readline to treat it as a nop. However, readline treats it as the first part of a multi-byte character. T= he patch above fixes this, and allows it to be recognized as UTF8_SINGLEBYTE. Consequently, we have a different call stack when ^C hit us, and the problem doesn't trigger. --=20 You are receiving this mail because: You are on the CC list for the bug.=