Unverified Commit cd0f710b authored by Jim Brunner's avatar Jim Brunner Committed by GitHub
Browse files

fix minor memory leak in rewriteConfigSds (#9762)

parent c22d3684
...@@ -1066,7 +1066,7 @@ void rewriteConfigStringOption(struct rewriteConfigState *state, const char *opt ...@@ -1066,7 +1066,7 @@ void rewriteConfigStringOption(struct rewriteConfigState *state, const char *opt
} }
/* Rewrite a SDS string option. */ /* Rewrite a SDS string option. */
void rewriteConfigSdsOption(struct rewriteConfigState *state, const char *option, sds value, const sds defvalue) { void rewriteConfigSdsOption(struct rewriteConfigState *state, const char *option, sds value, const char *defvalue) {
int force = 1; int force = 1;
sds line; sds line;
...@@ -1078,7 +1078,7 @@ void rewriteConfigSdsOption(struct rewriteConfigState *state, const char *option ...@@ -1078,7 +1078,7 @@ void rewriteConfigSdsOption(struct rewriteConfigState *state, const char *option
} }
/* Set force to zero if the value is set to its default. */ /* Set force to zero if the value is set to its default. */
if (defvalue && sdscmp(value, defvalue) == 0) force = 0; if (defvalue && strcmp(value, defvalue) == 0) force = 0;
line = sdsnew(option); line = sdsnew(option);
line = sdscatlen(line, " ", 1); line = sdscatlen(line, " ", 1);
...@@ -1634,7 +1634,7 @@ static void sdsConfigGet(client *c, typeData data) { ...@@ -1634,7 +1634,7 @@ static void sdsConfigGet(client *c, typeData data) {
} }
static void sdsConfigRewrite(typeData data, const char *name, struct rewriteConfigState *state) { static void sdsConfigRewrite(typeData data, const char *name, struct rewriteConfigState *state) {
rewriteConfigSdsOption(state, name, *(data.sds.config), data.sds.default_value ? sdsnew(data.sds.default_value) : NULL); rewriteConfigSdsOption(state, name, *(data.sds.config), data.sds.default_value);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment