]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a memory leak in shell.c. Reported on the mailing list. This has only been inform...
authordanielk1977 <danielk1977@noemail.net>
Tue, 3 Jul 2007 05:31:16 +0000 (05:31 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 3 Jul 2007 05:31:16 +0000 (05:31 +0000)
FossilOrigin-Name: a008905b39e7d4cd5b39db4906eb3b678e3ee8b7

manifest
manifest.uuid
src/shell.c

index 33a48f55ae72f083fd376ff857ae86b4ac2f6f3e..a2ef377573375f2cb2dae8b79139da75ede85e48 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\scomment\stypo\sreported\son\sthe\smailing\slist.\s(CVS\s4152)
-D 2007-07-02T19:31:27
+C Fix\sa\smemory\sleak\sin\sshell.c.\sReported\son\sthe\smailing\slist.\sThis\shas\sonly\sbeen\sinformally\stested.\s(CVS\s4153)
+D 2007-07-03T05:31:16
 F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -106,7 +106,7 @@ F src/printf.c 9b3048d270e8bb2f8b910b491ac3aadece6cfab2
 F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
 F src/select.c e363327d0eba8d758ab00055de962a3bb0bc213e
 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
-F src/shell.c 4b0fc3c76a9f23a1c963e01703c0fbbca1b5c34d
+F src/shell.c e7534cce78398bc1cac4a643e931fc6221c2897e
 F src/sqlite.h.in bbcc5481af9f40ce5762c323cf555581a025f3de
 F src/sqlite3ext.h 95575e0d175a0271fe2c3232c0d11e8720ed6887
 F src/sqliteInt.h 81183ae71162818bf60478e738ff68604128bb06
@@ -517,7 +517,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P dee1a0fd28e8341af6523ab0c5628b671d7d2811
-R 748ebb7d5611da509fc36402c86fe12b
-U drh
-Z 10e512aabfacbf99d78b5a9941c7ad88
+P 25e6df9cdd7d0cbb2bdee9ce76806cfd08314212
+R 1119faa3ec9fa2274abccccd3467ef67
+U danielk1977
+Z aeb398c67bd2b4b8c263b0b6ba675a9a
index 41c83f83e8728bf3d33e4577c0b5fbe9240b9863..f1ed5ab4214ca369669e0c2cf0b5c506d2b3d19e 100644 (file)
@@ -1 +1 @@
-25e6df9cdd7d0cbb2bdee9ce76806cfd08314212
\ No newline at end of file
+a008905b39e7d4cd5b39db4906eb3b678e3ee8b7
\ No newline at end of file
index d48906b2f4dd4891561931f12abb8578ac6b1b54..cb39eb89024c167f5bf766532fc845ec7cdb9b83 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.163 2007/06/20 13:10:01 drh Exp $
+** $Id: shell.c,v 1.164 2007/07/03 05:31:16 danielk1977 Exp $
 */
 #include <stdlib.h>
 #include <string.h>
@@ -1590,7 +1590,7 @@ static int _is_command_terminator(const char *zLine){
 ** Return the number of errors.
 */
 static int process_input(struct callback_data *p, FILE *in){
-  char *zLine;
+  char *zLine = 0;
   char *zSql = 0;
   int nSql = 0;
   char *zErrMsg;
@@ -1601,6 +1601,7 @@ static int process_input(struct callback_data *p, FILE *in){
 
   while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
     fflush(p->out);
+    free(zLine);
     zLine = one_input_line(zSql, in);
     if( zLine==0 ){
       break;  /* We have reached EOF */
@@ -1614,7 +1615,6 @@ static int process_input(struct callback_data *p, FILE *in){
     if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue;
     if( zLine && zLine[0]=='.' && nSql==0 ){
       rc = do_meta_command(zLine, p);
-      free(zLine);
       if( rc==2 ){
         break;
       }else if( rc ){
@@ -1649,7 +1649,6 @@ static int process_input(struct callback_data *p, FILE *in){
       memcpy(&zSql[nSql], zLine, len+1);
       nSql += len;
     }
-    free(zLine);
     if( zSql && _ends_with_semicolon(zSql, nSql) && sqlite3_complete(zSql) ){
       p->cnt = 0;
       open_db(p);
@@ -1680,6 +1679,7 @@ static int process_input(struct callback_data *p, FILE *in){
     if( !_all_whitespace(zSql) ) printf("Incomplete SQL: %s\n", zSql);
     free(zSql);
   }
+  free(zLine);
   return errCnt;
 }