From 0ad8faccd4c33d788445a023adead9f8159c5090 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Mon, 22 May 2023 21:45:40 +1100
Subject: [PATCH] fix memory allocation

---
 src/lib66/exec/ssexec_reconfigure.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/lib66/exec/ssexec_reconfigure.c b/src/lib66/exec/ssexec_reconfigure.c
index 3823b14d..6c4d76ba 100644
--- a/src/lib66/exec/ssexec_reconfigure.c
+++ b/src/lib66/exec/ssexec_reconfigure.c
@@ -134,7 +134,7 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
         info->opt_tree = 0 ;
 
         unsigned int m = 0 ;
-        int nargc = 2 + nservice + siglen ;
+        int nargc = 3 + nservice + siglen ;
         char const *prog = PROG ;
         char const *newargv[nargc] ;
 
@@ -150,16 +150,17 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
                 newargv[m++] = name ;
         }
 
-        newargv[m++] = 0 ;
+        newargv[m] = 0 ;
 
         PROG = "stop" ;
-        e = ssexec_stop(nargc, newargv, info) ;
+        e = ssexec_stop(m, newargv, info) ;
         PROG = prog ;
         if (e)
             goto freed ;
 
         info->treename.len = 0 ;
-        auto_stra(&info->treename, tree) ;
+        if (!auto_stra(&info->treename, tree))
+            log_die_nomem("stralloc") ;
         info->opt_tree = 1 ;
     }
 
@@ -185,10 +186,10 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
                 newargv[m++] = name ;
         }
 
-        newargv[m++] = 0 ;
+        newargv[m] = 0 ;
 
         PROG= "start" ;
-        e = ssexec_start(--m, newargv, info) ;
+        e = ssexec_start(m, newargv, info) ;
         PROG = prog ;
     }
 
-- 
GitLab