Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/libexec/ld.elf_so/xmalloc.c,v rcsdiff: /ftp/cvs/cvsroot/src/libexec/ld.elf_so/xmalloc.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.11 retrieving revision 1.11.10.1 diff -u -p -r1.11 -r1.11.10.1 --- src/libexec/ld.elf_so/xmalloc.c 2011/05/25 14:41:46 1.11 +++ src/libexec/ld.elf_so/xmalloc.c 2013/02/25 00:28:03 1.11.10.1 @@ -1,4 +1,4 @@ -/* $NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $ */ +/* $NetBSD: xmalloc.c,v 1.11.10.1 2013/02/25 00:28:03 tls Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -77,7 +77,7 @@ #include #ifndef lint -__RCSID("$NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $"); +__RCSID("$NetBSD: xmalloc.c,v 1.11.10.1 2013/02/25 00:28:03 tls Exp $"); #endif /* not lint */ #include @@ -369,12 +369,13 @@ irealloc(void *cp, size_t nbytes) *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC; #endif return(cp); - } else - xfree(cp); + } if ((res = imalloc(nbytes)) == NULL) return (NULL); - if (cp != res) /* common optimization if "compacting" */ + if (cp != res) { /* common optimization if "compacting" */ memcpy(res, cp, (nbytes < onb) ? nbytes : onb); + xfree(cp); + } return (res); }