* Fixed an error in the realloc() function in mapmalloc.c that sometimes

caused memory to be overwritten because memcpy(new, old, size) was called
  with the size of 'new' if 'new' was larger than 'old'.
This commit is contained in:
Gunnar Ritter 2005-02-17 20:38:02 +00:00
parent 6afc996872
commit ebbbfc8bd2
2 changed files with 5 additions and 2 deletions

View File

@ -40,6 +40,9 @@ Release ...
* Ex does not exit on errors immediately anymore if standard input is not
a terminal but a pipe or regular file.
* The 'substitute' ex command can now be abbreviated as 'sub', 'subst' etc.
* Fixed an error in the realloc() function in mapmalloc.c that sometimes
caused memory to be overwritten because memcpy(new, old, size) was called
with the size of 'new' if 'new' was larger than 'old'.
Release 1/19/05
* The last release erroneously made 'X' work like 'x' in visual mode. It now

View File

@ -5,7 +5,7 @@
* September 2001.
*/
/* Sccsid @(#)mapmalloc.c 1.14 (gritter) 11/26/04 */
/* Sccsid @(#)mapmalloc.c 1.15 (gritter) 2/17/05 */
/* ====================================================================
* Copyright (c) 1999-2000 Ralf S. Engelschall. All rights reserved.
@ -508,7 +508,7 @@ realloc(char *ptr, size_t usize)
}
if ((vp = malloc(usize)) == NULL)
return NULL;
memcpy(vp, ptr, usize);
memcpy(vp, ptr, mc->mc_usize);
free(ptr);
return vp;
}