SQLite Forum

memory leaks in sqlite3.c:23618
Login
Looks like in this edge case, the code is jumping out of `"do_meta_command"` function without freeing "zLike".

Below is a patch@[4e1db8e9a9ee37](https://sqlite.org/src/info/4e1db8e9a9ee37). This clears the sanitizer trap in my test.


```
==================================================================
--- src/shell.c.in
+++ src/shell.c.in
@@ -7493,10 +7493,11 @@
         if( strcmp(z,"preserve-rowids")==0 ){
 #ifdef SQLITE_OMIT_VIRTUALTABLE
           raw_printf(stderr, "The --preserve-rowids option is not compatible"
                              " with SQLITE_OMIT_VIRTUALTABLE\n");
           rc = 1;
+          if( zLike ) sqlite3_free(zLike);
           goto meta_command_exit;
 #else
           ShellSetFlag(p, SHFLG_PreserveRowid);
 #endif
         }else
@@ -7504,10 +7505,11 @@
           ShellSetFlag(p, SHFLG_Newlines);
         }else
         {
           raw_printf(stderr, "Unknown option \"%s\" on \".dump\"\n", azArg[i]);
           rc = 1;
+          if( zLike ) sqlite3_free(zLike);
           goto meta_command_exit;
         }
       }else if( zLike ){
         zLike = sqlite3_mprintf("%z OR name LIKE %Q ESCAPE '\\'",
                 zLike, azArg[i]);


```