Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Bad autoloaded parameter in module crashes shell
- X-seq: zsh-workers 51460
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] Bad autoloaded parameter in module crashes shell
- Date: Sat, 18 Feb 2023 09:03:44 -0800
- Archived-at: <https://zsh.org/workers/51460>
- List-id: <zsh-workers.zsh.org>
When setsparam() fails during add_autoparam(), the shell crashes.
Patch attached.
I'm not entirely sure -1 is the correct value to return on this error.
diff --git a/Src/module.c b/Src/module.c
index 6cf442270..a6005f30b 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -1198,6 +1198,7 @@ add_autoparam(const char *module, const char *pnam, int flags)
{
Param pm;
int ret;
+ int ne = noerrs;
queue_signals();
if ((ret = checkaddparam(pnam, (flags & FEAT_IGNORE)))) {
@@ -1212,14 +1213,18 @@ add_autoparam(const char *module, const char *pnam, int flags)
return ret == 2 ? 0 : -1;
}
- pm = setsparam(dupstring(pnam), ztrdup(module));
-
- pm->node.flags |= PM_AUTOLOAD;
- if (flags & FEAT_AUTOALL)
- pm->node.flags |= PM_AUTOALL;
+ noerrs = 2;
+ if ((pm = setsparam(dupstring(pnam), ztrdup(module)))) {
+ pm->node.flags |= PM_AUTOLOAD;
+ if (flags & FEAT_AUTOALL)
+ pm->node.flags |= PM_AUTOALL;
+ ret = 0;
+ } else
+ ret = -1;
+ noerrs = ne;
unqueue_signals();
- return 0;
+ return ret;
}
/* Remove a parameter added with add_autoparam() */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author