diff options
Diffstat (limited to 'Src/Zle')
-rw-r--r-- | Src/Zle/comp.h | 3 | ||||
-rw-r--r-- | Src/Zle/compcore.c | 31 | ||||
-rw-r--r-- | Src/Zle/compctl.c | 5 | ||||
-rw-r--r-- | Src/Zle/complist.c | 20 | ||||
-rw-r--r-- | Src/Zle/compresult.c | 79 |
5 files changed, 132 insertions, 6 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index a8be74d03..34da2cabb 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -76,6 +76,9 @@ struct cmgroup { int totl; /* total length */ int shortest; /* length of shortest match */ Cmgroup perm; /* perm. alloced version of this group */ +#ifdef ZSH_HEAP_DEBUG + Heapid heap_id; +#endif }; diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index fa8b8c11f..9c6f0673a 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -405,6 +405,11 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat) } else if (nmatches == 1 || (nmatches > 1 && !diffmatches)) { /* Only one match. */ Cmgroup m = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(m->heap_id)) { + HEAP_ERROR(m->heap_id); + } +#endif while (!m->mcount) m = m->next; @@ -509,6 +514,11 @@ after_complete(UNUSED(Hookdef dummy), int *dat) int ret; cdat.matches = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(cdat.matches->heap_id)) { + HEAP_ERROR(cdat.matches->heap_id); + } +#endif cdat.num = nmatches; cdat.nmesg = nmessages; cdat.cur = NULL; @@ -987,6 +997,11 @@ makecomplist(char *s, int incmd, int lst) diffmatches = odm; validlist = 1; amatches = lastmatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(amatches->heap_id)) { + HEAP_ERROR(amatches->heap_id); + } +#endif lmatches = lastlmatches; if (pmatches) { freematches(pmatches, 1); @@ -2959,6 +2974,11 @@ begcmgroup(char *n, int flags) Cmgroup p = amatches; while (p) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(p->heap_id)) { + HEAP_ERROR(p->heap_id); + } +#endif if (p->name && flags == (p->flags & (CGF_NOSORT|CGF_UNIQALL|CGF_UNIQCON)) && !strcmp(n, p->name)) { @@ -2975,6 +2995,9 @@ begcmgroup(char *n, int flags) } } mgroup = (Cmgroup) zhalloc(sizeof(struct cmgroup)); +#ifdef ZSH_HEAP_DEBUG + mgroup->heap_id = last_heap_id; +#endif mgroup->name = dupstring(n); mgroup->lcount = mgroup->llcount = mgroup->mcount = mgroup->ecount = mgroup->ccount = 0; @@ -3295,6 +3318,11 @@ permmatches(int last) fi = 1; } while (g) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif if (fi != ofi || !g->perm || g->new) { if (fi) /* We have no matches, try ignoring fignore. */ @@ -3323,6 +3351,9 @@ permmatches(int last) diffmatches = 1; n = (Cmgroup) zshcalloc(sizeof(struct cmgroup)); +#ifdef ZSH_HEAP_DEBUG + n->heap_id = HEAPID_PERMANENT; +#endif if (g->perm) { g->perm->next = NULL; diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index 873d9287a..170efff3f 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -1838,6 +1838,11 @@ ccmakehookfn(UNUSED(Hookdef dummy), struct ccmakedat *dat) diffmatches = odm; validlist = 1; amatches = lastmatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(amatches->heap_id)) { + HEAP_ERROR(amatches->heap_id); + } +#endif lmatches = lastlmatches; if (pmatches) { freematches(pmatches, 1); diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 6d0da448c..fdca7a99f 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1363,6 +1363,11 @@ compprintlist(int showall) while (g) { char **pp = g->ylist; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif if ((e = g->expls)) { int l; @@ -1952,6 +1957,11 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat) Cmgroup oamatches = amatches; amatches = dat->matches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(amatches->heap_id)) { + HEAP_ERROR(amatches->heap_id); + } +#endif noselect = 0; @@ -2640,6 +2650,11 @@ domenuselect(Hookdef dummy, Chdata dat) s->mlbeg = mlbeg; memcpy(&(s->info), &minfo, sizeof(struct menuinfo)); s->amatches = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(amatches->heap_id)) { + HEAP_ERROR(amatches->heap_id); + } +#endif s->pmatches = pmatches; s->lastmatches = lastmatches; s->lastlmatches = lastlmatches; @@ -2835,6 +2850,11 @@ domenuselect(Hookdef dummy, Chdata dat) if (lastmatches) freematches(lastmatches, 0); amatches = u->amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(amatches->heap_id)) { + HEAP_ERROR(amatches->heap_id); + } +#endif pmatches = u->pmatches; lastmatches = u->lastmatches; lastlmatches = u->lastlmatches; diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index f2729a0fe..c0e5ff3d8 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -906,7 +906,14 @@ do_allmatches(UNUSED(int end)) for (minfo.group = amatches; minfo.group && !(minfo.group)->mcount; - minfo.group = (minfo.group)->next); + minfo.group = (minfo.group)->next) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(minfo.group->heap_id)) { + HEAP_ERROR(minfo.group->heap_id); + } +#endif + } + mc = (minfo.group)->matches; @@ -1172,6 +1179,11 @@ do_single(Cmatch m) struct chdata dat; dat.matches = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(dat.matches->heap_id)) { + HEAP_ERROR(dat.matches->heap_id); + } +#endif dat.num = nmatches; dat.cur = m; @@ -1210,8 +1222,14 @@ do_menucmp(int lst) do { if (!*++(minfo.cur)) { do { - if (!(minfo.group = (minfo.group)->next)) + if (!(minfo.group = (minfo.group)->next)) { minfo.group = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(minfo.group->heap_id)) { + HEAP_ERROR(minfo.group->heap_id); + } +#endif + } } while (!(minfo.group)->mcount); minfo.cur = minfo.group->matches; } @@ -1291,12 +1309,18 @@ accept_last(void) Cmgroup g; Cmatch *m; - for (g = amatches, m = NULL; g && (!m || !*m); g = g->next) + for (g = amatches, m = NULL; g && (!m || !*m); g = g->next) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif for (m = g->matches; *m; m++) if (!hasbrpsfx(*m, minfo.prebr, minfo.postbr)) { showinglist = -2; break; } + } } } menuacc++; @@ -1381,7 +1405,13 @@ do_ambig_menu(void) insgnum = comp_mod(insgnum, lastpermgnum); for (minfo.group = amatches; minfo.group && (minfo.group)->num != insgnum + 1; - minfo.group = (minfo.group)->next); + minfo.group = (minfo.group)->next) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(minfo.group->heap_id)) { + HEAP_ERROR(minfo.group->heap_id); + } +#endif + } if (!minfo.group || !(minfo.group)->mcount) { minfo.cur = NULL; minfo.asked = 0; @@ -1393,8 +1423,14 @@ do_ambig_menu(void) insmnum = comp_mod(insmnum, lastpermmnum); for (minfo.group = amatches; minfo.group && (minfo.group)->mcount <= insmnum; - minfo.group = (minfo.group)->next) + minfo.group = (minfo.group)->next) { insmnum -= (minfo.group)->mcount; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(minfo.group->heap_id)) { + HEAP_ERROR(minfo.group->heap_id); + } +#endif + } if (!minfo.group) { minfo.cur = NULL; minfo.asked = 0; @@ -1483,6 +1519,11 @@ calclist(int showall) int nl = 0, l, glong = 1, gshort = zterm_columns, ndisp = 0, totl = 0; int hasf = 0; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif g->flags |= CGF_PACKED | CGF_ROWS; if (!onlyexpl && pp) { @@ -1624,6 +1665,11 @@ calclist(int showall) for (g = amatches; g; g = g->next) { glines = 0; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif zfree(g->widths, 0); g->widths = NULL; @@ -1858,6 +1904,11 @@ calclist(int showall) else for (g = amatches; g; g = g->next) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif zfree(g->widths, 0); g->widths = NULL; } @@ -1945,6 +1996,11 @@ printlist(int over, CLPrintFunc printm, int showall) for (g = amatches; g; g = g->next) { char **pp = g->ylist; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif if ((e = g->expls)) { int l; @@ -2144,7 +2200,13 @@ bld_all_str(Cmatch all) buf[0] = '\0'; - for (g = amatches; g && !g->mcount; g = g->next); + for (g = amatches; g && !g->mcount; g = g->next) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif + } mp = g->matches; while (1) { @@ -2262,6 +2324,11 @@ list_matches(UNUSED(Hookdef dummy), UNUSED(void *dummy2)) #endif dat.matches = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(dat.matches->heap_id)) { + HEAP_ERROR(dat.matches->heap_id); + } +#endif dat.num = nmatches; dat.cur = NULL; ret = runhookdef(COMPLISTMATCHESHOOK, (void *) &dat); |