aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cbs.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/cbs.h b/cbs.h
index 47f0031..1c3b833 100644
--- a/cbs.h
+++ b/cbs.h
@@ -367,7 +367,14 @@ void
cbsinit(int argc, char **argv)
{
_cbs_argc = argc;
- _cbs_argv = argv;
+ _cbs_argv = bufalloc(NULL, argc, sizeof(char *));
+ for (int i = 0; i < argc; i++) {
+ if (!(_cbs_argv[i] = strdup(argv[i]))) {
+ /* We might not have set _cbs_argv[0] yet, so we can’t use die() */
+ fprintf(stderr, "%s: strdup: %s\n", *argv, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ }
}
static size_t