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

Fix a whole host of newly discovered memory leaks the occur after a

failure of realloc(). (CVS 2696)

FossilOrigin-Name: 4686d649756a0aa301ade901ac49c89a976c5402
This commit is contained in:
drh
2005-09-16 02:38:09 +00:00
parent b38ad9991c
commit 53f733c7ae
11 changed files with 97 additions and 49 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.144 2005/08/27 01:51:44 drh Exp $
** $Id: util.c,v 1.145 2005/09/16 02:38:11 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -366,6 +366,20 @@ char *sqlite3StrNDup(const char *z, int n){
}
#endif /* !defined(SQLITE_MEMDEBUG) */
/*
** Reallocate a buffer to a different size. This is similar to
** sqliteRealloc() except that if the allocation fails the buffer
** is freed.
*/
void sqlite3ReallocOrFree(void **ppBuf, int newSize){
void *pNew = sqliteRealloc(*ppBuf, newSize);
if( pNew ){
*ppBuf = pNew;
}else{
sqliteFree(*ppBuf);
}
}
/*
** Create a string from the 2nd and subsequent arguments (up to the
** first NULL argument), store the string in memory obtained from