Re: [PATCH] Use realparamtab and don't dereference special parameters in zle code
Bart Schaefer <[email protected]> Mon, 22 Jun 2026 21:28:49 -0700
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <CAH+w=7ZyvcBoD38BmeZZnoC=Q9TeuX7NWBZzd2-8-jP7FvRCAg@mail.gmail.com> |
On Thu, Jun 18, 2026 at 4:56 PM Philippe Altherr <[email protected]> wrote: > > - Use realparamtab and don't dereference special parameters in zle code > In makecompparams(), is it really always guaranteed that paramtab == realparamtab on entry to the function? (See hardwired reset at the end.) The save/restore with "tht" seems like otherwise-harmless defensive programming. (Please excuse that copy/paste may have squashed tab indentation) @@ -1340,23 +1339,21 @@ void makecompparams(void) { Param cpm; - HashTable tht; addcompparams(comprparams, comprpms); if (!(cpm = createparam( COMPSTATENAME, PM_SPECIAL|PM_REMOVABLE|PM_SINGLE|PM_LOCAL|PM_HASHED))) - cpm = (Param) paramtab->getnode(paramtab, COMPSTATENAME); - DPUTS(!cpm, "param not set in makecompparams"); + cpm = (Param) realparamtab->getnode2(realparamtab, COMPSTATENAME); + DPUTS1(!cpm, "param %s not set in makecompparams", COMPSTATENAME); comprpms[CPN_COMPSTATE] = cpm; - tht = paramtab; cpm->level = locallevel + 1; cpm->gsu.h = &compstate_gsu; cpm->u.hash = paramtab = newparamtable(31, COMPSTATENAME); addcompparams(compkparams, compkpms); - paramtab = tht; + paramtab = realparamtab; } > Why remove PM_NAMEREF in makezleparams()? Just because right now there are no ZLE parameters that are named references doesn't mean there might not be at some point? switch(PM_TYPE(zp->type)) { case PM_SCALAR: - case PM_NAMEREF: pm->gsu.s = zp->gsu; break;