- // don't blank old optargs if our new argc lives in the old optargs.
- if (argv>=toys.optargs && argv<=toys.optargs+toys.optc) toys.optargs = 0;
+ // Return if stack depth getting noticeable (proxy for leaked heap, etc).
+
+ // Compiler writers have decided subtracting char * is undefined behavior,
+ // so convert to integers. (LP64 says sizeof(long)==sizeof(pointer).)
+ if (!CFG_TOYBOX_NORECURSE)
+ if (toys.stacktop && labs((long)toys.stacktop-(long)&which)>6000) return;
+
+ // Return if we need to re-exec to acquire root via suid bit.
+ if (toys.which && (which->flags&TOYFLAG_ROOTONLY) && toys.wasroot) return;