summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony@daylessday.org>2015-02-16 16:15:16 +0300
committerdormando <dormando@rydia.net>2015-11-18 16:16:32 -0800
commit4a4cac91ab2b7e8c4fce056fab94c6f20a3c9e59 (patch)
tree246c958a2b5bbb1432ec60f62687e832bdf7845a
parenta7e54510c67228227f90a07c6b11fe46ef6c219b (diff)
downloadmemcached-4a4cac91ab2b7e8c4fce056fab94c6f20a3c9e59.tar.gz
copy original arg to avoid changing it with getsubopt()
-rw-r--r--memcached.c5
1 files 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);