mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-30 02:52:12 +01:00
49377: fix segfault by 'bindkey -d' with reordered keymapnamtab
(cherry picked from commit 2a7945a900
)
This commit is contained in:
parent
f2ae864016
commit
9d20469c03
3 changed files with 40 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
|||
2022-01-27 dana <dana@dana.is>
|
||||
|
||||
* Jun-ichi Takimoto: 49377: Src/Zle/zle_keymap.c,
|
||||
Test/X03zlebindkey.ztst: fix segfault by 'bindkey -d' with
|
||||
reordered keymapnamtab
|
||||
|
||||
* Jun-ichi Takimoto: 47560: configure.ac, aczsh.m4: add necessary
|
||||
includes or prototypes for the tests in configure (fix errors in
|
||||
macOS 11)
|
||||
|
|
|
@ -155,7 +155,7 @@ createkeymapnamtab(void)
|
|||
keymapnamtab = newhashtable(7, "keymapnamtab", NULL);
|
||||
|
||||
keymapnamtab->hash = hasher;
|
||||
keymapnamtab->emptytable = emptyhashtable;
|
||||
keymapnamtab->emptytable = emptykeymapnamtab;
|
||||
keymapnamtab->filltable = NULL;
|
||||
keymapnamtab->cmpnodes = strcmp;
|
||||
keymapnamtab->addnode = addhashnode;
|
||||
|
@ -178,6 +178,26 @@ makekeymapnamnode(Keymap keymap)
|
|||
return kmn;
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
emptykeymapnamtab(HashTable ht)
|
||||
{
|
||||
struct hashnode *hn, *hp;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ht->hsize; i++) {
|
||||
for (hn = ht->nodes[i]; hn;) {
|
||||
KeymapName kmn = (KeymapName) hn;
|
||||
hp = hn->next;
|
||||
zsfree(kmn->nam);
|
||||
unrefkeymap(kmn->keymap);
|
||||
zfree(kmn, sizeof(*kmn));
|
||||
hn = hp;
|
||||
}
|
||||
ht->nodes[i] = NULL;
|
||||
}
|
||||
ht->ct = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reference a keymap from a keymapname.
|
||||
|
|
|
@ -143,3 +143,18 @@
|
|||
>CURSOR: 18
|
||||
>BUFFER: echo $(( ##x ) ##x ) y
|
||||
>CURSOR: 22
|
||||
|
||||
bindkey -d
|
||||
for name in a b c d e; bindkey -N $name
|
||||
bindkey -d
|
||||
bindkey -l
|
||||
0:delete all keymaps after expanding keymapnamtab
|
||||
>.safe
|
||||
>command
|
||||
>emacs
|
||||
>isearch
|
||||
>main
|
||||
>vicmd
|
||||
>viins
|
||||
>viopp
|
||||
>visual
|
||||
|
|
Loading…
Reference in a new issue