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

@ -1,5 +1,5 @@
C If\sthe\sdatabase\sfilename\sis\san\sempty\sstring,\sopen\sa\stemporary\sfile\sto\shold\nthe\sdatabase.\s\sTicket\s#432.\s(CVS\s1085)
D 2003-08-26T11:25:58
C Fix\sa\sbug\sin\ssqliteRealloc()\sthat\sonly\soccurs\sif\sthere\sis\smemory\scorruption\nand\sdebugging\sis\senabled.\s\sTicket\s#421.\s(CVS\s1086)
D 2003-08-26T11:29:08
F Makefile.in f7e916ae863393827fa6a4cb292e3398096edcf1
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -57,7 +57,7 @@ F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
F src/tokenize.c 2ba93fe10d5f57f0cc20b07417c3244a30c324b3
F src/trigger.c 474581eaab388233df01bb019e558af2965decbf
F src/update.c 24260b4fda00c9726d27699a0561d53c0dccc397
F src/util.c 9ab0f573d31ad8c3cf1fcb6bef7a6299e09463fa
F src/util.c f16efa2d60bfd4e31ae06b07ed149557e828d294
F src/vacuum.c e4724eade07e4cf8897060a8cf632dbd92408eeb
F src/vdbe.c fb7f2fc00cd3400ca7e7b10b2b6cc692dfa8c59b
F src/vdbe.h d853ed6cc4727fa9e8ace6187c55afcf817041dd
@ -168,7 +168,7 @@ F www/speed.tcl 2f6b1155b99d39adb185f900456d1d592c4832b3
F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
P 2a40b46140720783cf4002fb9993f7f6766dbf5f
R 4050da4610851d1f5ae1706b56d51956
P da53369f0bf133b89b213bbb1ccea13eb93ab6ed
R c063bc5b44f0e04369457c8d8da286bc
U drh
Z cb698fdf25490f5d03df521b9648eaf1
Z d6308bf677dd6cb42320ba8033b5ea82

View File

@ -1 +1 @@
da53369f0bf133b89b213bbb1ccea13eb93ab6ed
eebc82b77dbf35a18d2eae47336038d4b67806c6

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;
}
}