From 3cb9493db033210c82bda3a3fdab5366fb7065ea Mon Sep 17 00:00:00 2001 From: jbj Date: Sun, 9 Mar 2008 20:24:45 +0000 Subject: - jbj: study the mess with splint, remove annotations where possible. - jbj: add -D_GNU_SOURCE for gcc to use __builtin_stpcpy when available. - jbj: add static inline stpcpy for the deprived. - jbj: use stpcpy to eliminate sprintf calls everywhere but popthelp.c - jbj: remove (now unneeded afaik) va_copy() from POPT_fprintf(). - jbj: inline strdup_fprintf() => POPT_fprintf keeping (unneeded?) va_copy. --- poptparse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'poptparse.c') diff --git a/poptparse.c b/poptparse.c index f203743..d196cc8 100644 --- a/poptparse.c +++ b/poptparse.c @@ -31,10 +31,12 @@ int poptDupArgv(int argc, const char **argv, return POPT_ERROR_MALLOC; argv2 = (void *) dst; dst += (argc + 1) * sizeof(*argv); + *dst = '\0'; for (i = 0; i < argc; i++) { argv2[i] = dst; - dst += strlen(strcpy(dst, argv[i])) + 1; + dst = stpcpy(dst, argv[i]); + dst++; /* trailing NUL */ } argv2[argc] = NULL; -- cgit v1.2.1