-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix segfault in unsetref+=(foo); add warning
Emanuele Torre (@emanuele6) writes: > Appending a non-empty indexed array to an unset nameref crashes > with a segmentation fault: > $ arch/*/bin/ksh -c 'typeset -n ref; ref+=(); typeset -p ref' > typeset -n ref > $ arch/*/bin/ksh -c 'typeset -n ref; ref+=(foo); typeset -p ref' > Segmentation fault (core dumped) [...] > Appending an associative array errors correctly: > $ arch/*/bin/ksh -c 'typeset -n ref; ref+=([foo]=bar); typeset -p ref' > arch/linux.i386-64/bin/ksh: ref: no reference name For consistency, this commit makes all array assignments to an unset nameref (using either = or +=) succeed, but print a warning that the nameref attribute is removed -- a bash-like bahaviour. I think that this will cause fewer backward compatibility problems than making such assignments error out, since they used to succeed in some cases (e.g. 'typeset -n ref; ref=(foo bar)' always worked). It does mean the associative array reproducer above now generates a warning instead of an error. src/cmd/ksh93/sh/name.c: nv_create(): - After dereferencing a nameref, if nv_isref(np) is still true, we know it must be an unset nameref. In that case, add a check for c==0 (the value occurring upon var=(foo) and var+=(foo)), and produce a warning instead of an error, as argued above. Resolves: #678
- Loading branch information
Showing
5 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters