Date: Thu, 21 Sep 1995 06:39:46 -0700 From: David Greenman <davidg@Root.COM> To: Bruce Evans <bde@freefall.freebsd.org> Cc: cvs-bin@freefall.freebsd.org, CVS-commiters@freefall.freebsd.org Subject: Re: cvs commit: src/bin/sh jobs.c Message-ID: <199509211339.GAA00413@corbin.Root.COM> In-Reply-To: Your message of "Thu, 21 Sep 95 06:24:22 PDT." <199509211324.GAA05821@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>bde 95/09/21 06:24:21 > > Modified: bin/sh jobs.c > Log: > Fix relocation of job table. > > while { sleep 1 & wait; } do echo 1; done > > corrupted the job table every 4th iteration. Hmmm... *************** *** 459,465 **** --- 459,472 ---- if (njobs == 0) { jobtab = ckmalloc(4 * sizeof jobtab[0]); } else { + struct job *ojp; + jp = ckmalloc((njobs + 4) * sizeof jobtab[0]); + for (i = njobs, ojp = jobtab; --i >= 0; + jp++, ojp++) + if (ojp->ps == &ojp->ps0) + ojp->ps = &jp->ps0; + jp -= njobs; bcopy(jobtab, jp, njobs * sizeof jp[0]); ckfree(jobtab); jobtab = jp; I'm concerned by what you're doing with 'jp' above. How is free() going to be able to free this after you've changed the address that was returned by malloc (jp -= njobs)? -DG
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199509211339.GAA00413>