diff options
author | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2021-09-08 09:51:43 +0900 |
---|---|---|
committer | dana <dana@dana.is> | 2022-02-12 07:22:15 -0600 |
commit | 9d20469c030ead700959fa3b95d7bc85bb9578a8 (patch) | |
tree | 880f4a1fe4fb9cb4d9bf34180846be4616c91353 /Src/Zle/zle_keymap.c | |
parent | f2ae864016340aed35270502aedbad6da9e6f1bf (diff) | |
download | zsh-9d20469c030ead700959fa3b95d7bc85bb9578a8.tar.gz zsh-9d20469c030ead700959fa3b95d7bc85bb9578a8.tar.xz zsh-9d20469c030ead700959fa3b95d7bc85bb9578a8.zip |
49377: fix segfault by 'bindkey -d' with reordered keymapnamtab
(cherry picked from commit 2a7945a900c8a1b1866ad31ee5e95db5b0ddb50a)
Diffstat (limited to 'Src/Zle/zle_keymap.c')
-rw-r--r-- | Src/Zle/zle_keymap.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index d13aed594..49b2a26ad 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -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. |