1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Fix a bug in sqliteRealloc() that only occurs if there is memory corruption

and debugging is enabled.  Ticket #421. (CVS 1086)

FossilOrigin-Name: eebc82b77dbf35a18d2eae47336038d4b67806c6
This commit is contained in:
drh
2003-08-26 11:29:07 +00:00
parent 901afd4341
commit 03ab7336cd
3 changed files with 11 additions and 10 deletions

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.66 2003/07/30 12:34:12 drh Exp $
** $Id: util.c,v 1.67 2003/08/26 11:29:08 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -160,14 +160,15 @@ void *sqliteRealloc_(void *oldP, int n, char *zFile, int line){
oldPi = oldP;
oldPi -= N_GUARD+1;
if( oldPi[0]!=0xdead1122 ){
fprintf(stderr,"Low-end memory corruption in realloc at 0x%x\n", (int)p);
fprintf(stderr,"Low-end memory corruption in realloc at 0x%x\n", (int)oldP);
return 0;
}
oldN = oldPi[N_GUARD];
oldK = (oldN+sizeof(int)-1)/sizeof(int);
for(i=0; i<N_GUARD; i++){
if( oldPi[oldK+N_GUARD+1+i]!=0xdead3344 ){
fprintf(stderr,"High-end memory corruption in realloc at 0x%x\n", (int)p);
fprintf(stderr,"High-end memory corruption in realloc at 0x%x\n",
(int)oldP);
return 0;
}
}