diff options
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/func.c b/src/func.c index 224f88f08..7b981df30 100644 --- a/src/func.c +++ b/src/func.c @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.168 2007/08/21 19:33:56 drh Exp $ +** $Id: func.c,v 1.169 2007/08/23 02:47:53 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -807,14 +807,17 @@ static void replaceFunc( if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){ zOut[j++] = zStr[i]; }else{ + u8 *zOld; nOut += nRep - nPattern; if( nOut>=SQLITE_MAX_LENGTH ){ sqlite3_result_error_toobig(context); sqlite3_free(zOut); return; } + zOld = zOut; zOut = sqlite3_realloc(zOut, (int)nOut); if( zOut==0 ){ + sqlite3_free(zOld); return; } memcpy(&zOut[j], zRep, nRep); |