Changeset 3440 for trunk/src/kash/eval.c


Ignore:
Timestamp:
Sep 10, 2020, 1:38:27 PM (5 years ago)
Author:
bird
Message:

kash: Must make sure nfile::expfname is initialized and set to NULL after use, or we risk copying random stuff. Fixed bug in copynodelist.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/eval.c

    r3438 r3440  
    104104STATIC void evalsubshell(shinstance *, union node *, int);
    105105STATIC void expredir(shinstance *, union node *);
     106STATIC void expredircleanup(shinstance *, union node *);
    106107STATIC void evalpipe(shinstance *, union node *);
    107108STATIC void evalcommand(shinstance *, union node *, int, struct backcmd *);
     
    251252                evaltree(psh, n->nredir.n, flags);
    252253                popredir(psh);
     254                expredircleanup(psh, n->nredir.redirect);
    253255                break;
    254256        case NSUBSHELL:
     
    473475                psh->exitstatus = waitforjob(psh, jp);
    474476        INTON;
     477        expredircleanup(psh, n->nredir.redirect);
    475478}
    476479
     
    504507                                fixredir(psh, redir, fn.list->text, 1);
    505508                        }
     509                        break;
     510                }
     511        }
     512}
     513
     514STATIC void
     515expredircleanup(shinstance *psh, union node *n)
     516{
     517        for (; n ; n = n->nfile.next) {
     518                struct arglist fn;
     519                fn.lastp = &fn.list;
     520                switch (n->type) {
     521                case NFROMTO:
     522                case NFROM:
     523                case NTO:
     524                case NCLOBBER:
     525                case NAPPEND:
     526                        n->nfile.expfname = NULL;
    506527                        break;
    507528                }
     
    12381259                        evalcommand_parent(psh, flags, args.lastarg, &args.smark, mode, jp,
    12391260                                                           args.pip, backcmd);
     1261                        expredircleanup(psh, cmd->ncmd.redirect);
    12401262                        return; /* at end of routine */
    12411263                }
     
    12481270                evalcommand_doit(psh, cmd, &args);
    12491271        }
     1272        expredircleanup(psh, cmd->ncmd.redirect);
    12501273}
    12511274
Note: See TracChangeset for help on using the changeset viewer.