plan9port

[fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port # fast
git clone https://src.adamsgaard.dk/plan9port.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit ab937b56dec51e002ef2e248a3bf9b183f848cc2
parent eb1392208cead07e9e413b5ad4dbd82069d87c30
Author: Russ Cox <rsc@swtch.com>
Date:   Sat,  6 Dec 2008 15:35:55 -0800

dc: clean up minor memory errors

Diffstat:
Msrc/cmd/dc.c | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/cmd/dc.c b/src/cmd/dc.c @@ -2103,14 +2103,13 @@ copy(Blk *hptr, int size) if(size > maxsize) maxsize = size; sz = length(hptr); - ptr = nalloc(hptr->beg, size); + ptr = malloc(size); if(ptr == 0) { - garbage("copy"); - if((ptr = nalloc(hptr->beg, size)) == 0) { - Bprint(&bout,"copy size %d\n",size); - ospace("copy"); - } + Bprint(&bout,"copy size %d\n",size); + ospace("copy"); } + memmove(ptr, hptr->beg, sz); + memset(ptr+sz, 0, size-sz); if((hdr = hfree) == 0) hdr = morehd(); hfree = (Blk *)hdr->rd;