mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix a crashing bug in history expansion
Reproducer: $ set -o histexpand $ echo foo !#^:h !#^:& /usr/local/bin/ksh: :&: no previous substitution ksh(80822,0x10bc2a5c0) malloc: *** error for object 0x10a13bae3: pointer being freed was not allocated ksh(80822,0x10bc2a5c0) malloc: *** set a breakpoint in malloc_error_break to debug Abort Analysis: In hist_expand(), the 'cc' variable has two functions: it holds a pointer to a malloc'ed copy of the current line, and is also used as a temporary pointer with functions like strchr(). After that temporary use, it is set to NULL again, because the 'done:' routine checks if it non-NULL to decide whether to free the pointer. But if an error occurs, the function may jump straight to 'done' without first setting cc to NULL if it had been used as a temporary pointer. It then tries to free an unallocated pointer. src/cmd/ksh93/edit/hexpand.c: hist_expand(): - Eliminate this bad practice by using a separate variable for temporary pointer purposes. (I was unable to reproduce the crash in a pty regression test, though it is consistently reproducible in a real interactive session. So I haven't added that test.)
This commit is contained in:
parent
0a1cc391bf
commit
cda8fc916f
3 changed files with 19 additions and 13 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||
#define SH_RELEASE_DATE "2022-01-20" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_DATE "2022-01-24" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
||||
|
||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue