Module Name: src
Committed By: christos
Date: Thu Jan 24 17:57:29 UTC 2013
Modified Files:
src/libexec/ld.elf_so: xmalloc.c
Log Message:
don't free cp before we copy it!
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/libexec/ld.elf_so/xmalloc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/libexec/ld.elf_so/xmalloc.c
diff -u src/libexec/ld.elf_so/xmalloc.c:1.11 src/libexec/ld.elf_so/xmalloc.c:1.12
--- src/libexec/ld.elf_so/xmalloc.c:1.11 Wed May 25 10:41:46 2011
+++ src/libexec/ld.elf_so/xmalloc.c Thu Jan 24 12:57:29 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $ */
+/* $NetBSD: xmalloc.c,v 1.12 2013/01/24 17:57:29 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -77,7 +77,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $");
+__RCSID("$NetBSD: xmalloc.c,v 1.12 2013/01/24 17:57:29 christos Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -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);
}