From ef4334667414f28bc427543ac39d995465886d6a Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 28 Jun 2011 22:02:42 +0000 Subject: [PATCH] Don't read beyond end of old buffer. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@39594 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/clib/realloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/clib/realloc.c b/compiler/clib/realloc.c index 6e2329de7c..8c9e03aa00 100644 --- a/compiler/clib/realloc.c +++ b/compiler/clib/realloc.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2007, The AROS Development Team. All rights reserved. + Copyright © 1995-2011, The AROS Development Team. All rights reserved. $Id$ ANSI C function realloc(). @@ -27,7 +27,7 @@ the new contents will be undefined. INPUTS - oldmen - What you got from malloc() or calloc(). + oldmem - What you got from malloc() or calloc(). size - The new size. RESULT @@ -81,6 +81,8 @@ copy: if (newmem) { + if (size > oldsize) + size = oldsize; CopyMem (oldmem, newmem, size); free (oldmem); } -- 2.11.4.GIT