From 4a4cac91ab2b7e8c4fce056fab94c6f20a3c9e59 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 16 Feb 2015 16:15:16 +0300 Subject: copy original arg to avoid changing it with getsubopt() --- memcached.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/memcached.c b/memcached.c index e135dd8..c76f18c 100644 --- a/memcached.c +++ b/memcached.c @@ -5109,7 +5109,7 @@ int main (int argc, char **argv) { enum hashfunc_type hash_type = JENKINS_HASH; uint32_t tocrawl; - char *subopts; + char *subopts, *subopts_orig; char *subopts_value; enum { MAXCONNS_FAST = 0, @@ -5387,7 +5387,7 @@ int main (int argc, char **argv) { settings.flush_enabled = false; break; case 'o': /* It's sub-opts time! */ - subopts = optarg; + subopts_orig = subopts = strdup(optarg); /* getsubopt() changes the original args */ while (*subopts != '\0') { @@ -5510,6 +5510,7 @@ int main (int argc, char **argv) { } } + free(subopts_orig); break; default: fprintf(stderr, "Illegal argument \"%c\"\n", c); -- cgit v1.2.1