mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-05 04:30:38 +03:00
Fix the ".genfkey" command of the CLI so that it does not leak memory
if sqlite3_realloc() fails. Ticket #3891. (CVS 6696) FossilOrigin-Name: a028d69c70ae961f418052a91aa1518e80a8ddf5
This commit is contained in:
11
src/shell.c
11
src/shell.c
@@ -12,7 +12,7 @@
|
||||
** This file contains code to implement the "sqlite" command line
|
||||
** utility for accessing SQLite databases.
|
||||
**
|
||||
** $Id: shell.c,v 1.209 2009/05/21 15:15:01 drh Exp $
|
||||
** $Id: shell.c,v 1.210 2009/05/31 17:16:10 drh Exp $
|
||||
*/
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
/* This needs to come before any includes for MSVC compiler */
|
||||
@@ -623,8 +623,15 @@ static void multireplace(
|
||||
}
|
||||
}
|
||||
if( (nOut+nCopy)>nMalloc ){
|
||||
char *zNew;
|
||||
nMalloc = 16 + (nOut+nCopy)*2;
|
||||
zOut = (char *)sqlite3_realloc(zOut, nMalloc);
|
||||
zNew = (char*)sqlite3_realloc(zOut, nMalloc);
|
||||
if( zNew==0 ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
return;
|
||||
}else{
|
||||
zOut = zNew;
|
||||
}
|
||||
}
|
||||
assert( nMalloc>=(nOut+nCopy) );
|
||||
memcpy(&zOut[nOut], zCopy, nCopy);
|
||||
|
||||
Reference in New Issue
Block a user