From 1b2901722e5de3ef8d29edb4481327e48bd3363c Mon Sep 17 00:00:00 2001
From: zwtmichael <zhuwentao5@huawei.com>
Date: Mon, 7 Aug 2023 15:10:32 +0800
Subject: [PATCH] fix segmentation violation

Signed-off-by: zwtmichael <zhuwentao5@huawei.com>
---
 src/shell.c.in | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/shell.c.in b/src/shell.c.in
index 543141c..d278988 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -11469,8 +11469,12 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
     }else if( strcmp(z,"-bail")==0 ){
       bail_on_error = 1;
     }else if( strcmp(z,"-nonce")==0 ){
-      free(data.zNonce);
-      data.zNonce = strdup(argv[++i]);
+      if( data.zNonce ) free(data.zNonce);
+        if( i+1 < argc ) data.zNonce = strdup(argv[++i]);
+        else{
+          data.zNonce = 0;
+            break;
+        }
     }else if( strcmp(z,"-safe")==0 ){
       /* no-op - catch this on the second pass */
     }
-- 
2.34.1.windows.1

