Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so don't free cp before we copy it!
details: https://anonhg.NetBSD.org/src/rev/d398911a4eb6
branches: trunk
changeset: 784312:d398911a4eb6
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 24 17:57:29 2013 +0000
description:
don't free cp before we copy it!
diffstat:
libexec/ld.elf_so/xmalloc.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (35 lines):
diff -r 399e3427a1fd -r d398911a4eb6 libexec/ld.elf_so/xmalloc.c
--- a/libexec/ld.elf_so/xmalloc.c Thu Jan 24 17:53:49 2013 +0000
+++ b/libexec/ld.elf_so/xmalloc.c Thu Jan 24 17:57:29 2013 +0000
@@ -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 @@
*(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);
}
Home |
Main Index |
Thread Index |
Old Index