diff options
author | dan <Dan Kennedy> | 2024-06-04 15:07:38 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2024-06-04 15:07:38 +0000 |
commit | 077f9b14f11c798e01def61f0e81c47859950d3a (patch) | |
tree | 1c7c08886bcfd43dca01b4437d4545885d7748ca /src | |
parent | c5a0ed7b436525f900432a2f3b72bd72af876558 (diff) | |
download | sqlite-077f9b14f11c798e01def61f0e81c47859950d3a.tar.gz sqlite-077f9b14f11c798e01def61f0e81c47859950d3a.zip |
Fix a couple of memory leaks in the shell tool code that could occur when processing errors.
FossilOrigin-Name: e84f09d469ee76a5b5e44baf6a69b90c69d4160fa4c32de04a96f868643acd96
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 7a9aa032b..546107138 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -8955,6 +8955,7 @@ static int do_meta_command(char *zLine, ShellState *p){ eputf("%s: empty file\n", sCtx.zFile); import_cleanup(&sCtx); rc = 1; + sqlite3_free(zCreate); goto meta_command_exit; } zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs); @@ -12749,8 +12750,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ if( azCmd[i][0]=='.' ){ rc = do_meta_command(azCmd[i], &data); if( rc ){ - free(azCmd); - return rc==2 ? 0 : rc; + if( rc==2 ) rc = 0; + goto shell_main_exit; } }else{ open_db(&data, 0); @@ -12763,8 +12764,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ eputf("Error: unable to process SQL: %s\n", azCmd[i]); } sqlite3_free(zErrMsg); - free(azCmd); - return rc!=0 ? rc : 1; + if( rc==0 ) rc = 1; + goto shell_main_exit; } } } @@ -12824,6 +12825,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ expertFinish(&data, 1, 0); } #endif + shell_main_exit: free(azCmd); set_table_name(&data, 0); if( data.db ){ |