commit ab937b56dec51e002ef2e248a3bf9b183f848cc2 from: Russ Cox date: Sat Dec 06 23:35:55 2008 UTC dc: clean up minor memory errors commit - eb1392208cead07e9e413b5ad4dbd82069d87c30 commit + ab937b56dec51e002ef2e248a3bf9b183f848cc2 blob - bdcfadeed24a65c43954a53a2a94e417cf19454a blob + fa7f09bcc25926b76c60e03b6ca551f37880684f --- src/cmd/dc.c +++ 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); - if(ptr == 0) { - garbage("copy"); - if((ptr = nalloc(hptr->beg, size)) == 0) { - Bprint(&bout,"copy size %d\n",size); - ospace("copy"); - } + ptr = malloc(size); + if(ptr == 0) { + 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;