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:
16
src/util.c
16
src/util.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user