]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Make use of poptDupArgv().
authorWayne Davison <wayne@opencoder.net>
Sat, 13 Jun 2020 06:10:44 +0000 (23:10 -0700)
committerWayne Davison <wayne@opencoder.net>
Sat, 13 Jun 2020 06:28:27 +0000 (23:28 -0700)
main.c

diff --git a/main.c b/main.c
index 155b178cecb40278209e1cd96e4e280077437d68..90ab43dbcc58ce8f1c037e67b48e805a008d7ad5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -26,6 +26,7 @@
 #if defined CONFIG_LOCALE && defined HAVE_LOCALE_H
 #include <locale.h>
 #endif
+#include <popt.h>
 
 extern int dry_run;
 extern int list_only;
@@ -1706,13 +1707,9 @@ int main(int argc,char *argv[])
                option_error();
                exit_cleanup(RERR_SYNTAX);
        }
-       if (write_batch) {
-               int j;
-               cooked_argc = argc;
-               cooked_argv = new_array(char*, argc+1);
-               for (j = 0; j <= argc; j++)
-                       cooked_argv[j] = argv[j];
-       }
+       if (write_batch
+        && poptDupArgv(argc, (const char **)argv, &cooked_argc, (const char ***)&cooked_argv) != 0)
+               out_of_memory("main");
 
        SIGACTMASK(SIGINT, sig_int);
        SIGACTMASK(SIGHUP, sig_int);