Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: hlgroup: fix in 52783 was incomplete, add same check in scangroup()



% typeset -A .zle.hlgroups
% zmodload -i zsh/hlgroup
% : ${.zle.hlgroups[select]}
% print ${(k).zle.esc}
zsh: segmentation fault

Also add check on !hlg too for paranoia, not sure if that can actually
happen, but getgroup has the same check.
---
 Src/Modules/hlgroup.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Src/Modules/hlgroup.c b/Src/Modules/hlgroup.c
index 1dc6ac2ef0..819b546960 100644
--- a/Src/Modules/hlgroup.c
+++ b/Src/Modules/hlgroup.c
@@ -124,6 +124,8 @@ scangroup(ScanFunc func, int flags, int sgr)
 	     PM_TYPE(v->pm->node.flags) != PM_HASHED)
 	return;
     hlg = v->pm->gsu.h->getfn(v->pm);
+    if (!hlg)
+	return;
 
     memset((void *)&pm, 0, sizeof(struct param));
     pm.node.flags = PM_SCALAR;
@@ -131,6 +133,8 @@ scangroup(ScanFunc func, int flags, int sgr)
 
     for (i = 0; i < hlg->hsize; i++)
 	for (hn = hlg->nodes[i]; hn; hn = hn->next) {
+	    if (((Param) hn)->node.flags & PM_UNSET)
+		continue;
 	    pm.u.str = convertattr(((Param) hn)->u.str, sgr);
 	    pm.node.nam = hn->nam;
 	    func(&pm.node, flags);
-- 
2.38.1





Messages sorted by: Reverse Date, Date, Thread, Author