diff options
author | drh <drh@noemail.net> | 2006-05-10 14:39:13 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-05-10 14:39:13 +0000 |
commit | c1f4494e658431a5ee2907f43dd97e43673dc52f (patch) | |
tree | 91e9880ec1d420ab20e05e758ef0f44fe954a5fa /src | |
parent | f3a5888dded5080861f5653e78f8814921a91e2b (diff) | |
download | sqlite-c1f4494e658431a5ee2907f43dd97e43673dc52f.tar.gz sqlite-c1f4494e658431a5ee2907f43dd97e43673dc52f.zip |
Out-of-memory checks added to tclsqlite.c and shell.c. Tickets #1805 and #1806. (CVS 3182)
FossilOrigin-Name: 364031d6e512b992a7147bbc8e046c20c0c5335a
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c | 6 | ||||
-rw-r--r-- | src/tclsqlite.c | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/shell.c b/src/shell.c index 6c0f6f46a..cc7969a5f 100644 --- a/src/shell.c +++ b/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.135 2006/03/19 13:00:25 drh Exp $ +** $Id: shell.c,v 1.136 2006/05/10 14:39:14 drh Exp $ */ #include <stdlib.h> #include <string.h> @@ -1471,6 +1471,10 @@ static void process_input(struct callback_data *p, FILE *in){ if( zLine[i]!=0 ){ nSql = strlen(zLine); zSql = malloc( nSql+1 ); + if( zSql==0 ){ + fprintf(stderr, "out of memory\n"); + exit(1); + } strcpy(zSql, zLine); } }else{ diff --git a/src/tclsqlite.c b/src/tclsqlite.c index cc9b8def0..875890d81 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.155 2006/03/16 16:19:56 drh Exp $ +** $Id: tclsqlite.c,v 1.156 2006/05/10 14:39:14 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -1108,11 +1108,13 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ if( i+1!=nCol ){ char *zErr; zErr = malloc(200 + strlen(zFile)); - sprintf(zErr, - "Error: %s line %d: expected %d columns of data but found %d", - zFile, lineno, nCol, i+1); - Tcl_AppendResult(interp, zErr, 0); - free(zErr); + if( zErr ){ + sprintf(zErr, + "Error: %s line %d: expected %d columns of data but found %d", + zFile, lineno, nCol, i+1); + Tcl_AppendResult(interp, zErr, 0); + free(zErr); + } zCommit = "ROLLBACK"; break; } |