]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:client: Do not call exit() in cmd_quit()
authorAndreas Schneider <asn@samba.org>
Wed, 29 Oct 2025 09:13:44 +0000 (10:13 +0100)
committerAnoop C S <anoopcs@samba.org>
Thu, 6 Nov 2025 08:56:31 +0000 (08:56 +0000)
We want to go through deallocation in the main function.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/client/client.c

index 1d10a4f90b2a2d1d859aaa8486dab0e21a51ba09..162ab131b34946b683d8ada96f8c3f2e4507304d 100644 (file)
@@ -1472,9 +1472,10 @@ static bool do_altname(const char *name)
 static int cmd_quit(void)
 {
        cli_shutdown(cli);
-       exit(0);
-       /* NOTREACHED */
-       return 0;
+       cli = NULL;
+
+       /* Use INT_MAX for QUIT */
+       return INT_MAX;
 }
 
 /****************************************************************************
@@ -5838,11 +5839,18 @@ static int process_command_string(const char *cmd_in)
 
                if ((i = process_tok(tok)) >= 0) {
                        rc = commands[i].fn();
+                       /* QUIT COMMAND */
+                       if (rc == INT_MAX) {
+                               TALLOC_FREE(tok);
+                               rc = 0;
+                               break;
+                       }
                } else if (i == -2) {
                        d_printf("%s: command abbreviation ambiguous\n",tok);
                } else {
                        d_printf("%s: command not found\n",tok);
                }
+               TALLOC_FREE(tok);
        }
 
        return rc;
@@ -6201,6 +6209,13 @@ static int process_stdin(void)
 
                if ((i = process_tok(tok)) >= 0) {
                        rc = commands[i].fn();
+                       /* QUIT COMMAND */
+                       if (rc == INT_MAX) {
+                               rc = 0;
+                               SAFE_FREE(line);
+                               TALLOC_FREE(tok);
+                               break;
+                       }
                } else if (i == -2) {
                        d_printf("%s: command abbreviation ambiguous\n",tok);
                } else {
@@ -6247,7 +6262,7 @@ static int process(const char *base_directory)
        if (cmdstr) {
                rc = process_command_string(cmdstr);
        } else {
-               process_stdin();
+               rc = process_stdin();
        }
 
        cli_shutdown(cli);