summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2019-05-07 10:25:13 +0200
committerGitHub <noreply@github.com>2019-05-07 10:25:13 +0200
commitf674e83215af5f15096bf53a27de6c4ccf21faae (patch)
treebb868311dd63fdb7e11ddf6c46ac9c5af438b187
parenta72ab70fee267759c1e22ddb76b7945a55b7b12c (diff)
parent48d591a010bbe4cf0c09a4d84a55ee3f31e5664f (diff)
downloadredis-f674e83215af5f15096bf53a27de6c4ccf21faae.tar.gz
Merge pull request #6082 from soloestoy/fix-config-rewrite-memleak
fix memory leak when rewrite config file
-rw-r--r--src/config.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c
index 1686743a0..7f0e9af89 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1711,12 +1711,11 @@ void rewriteConfigMarkAsProcessed(struct rewriteConfigState *state, const char *
* If the old file does not exist at all, an empty state is returned. */
struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
FILE *fp = fopen(path,"r");
- struct rewriteConfigState *state = zmalloc(sizeof(*state));
- char buf[CONFIG_MAX_LINE+1];
- int linenum = -1;
-
if (fp == NULL && errno != ENOENT) return NULL;
+ char buf[CONFIG_MAX_LINE+1];
+ int linenum = -1;
+ struct rewriteConfigState *state = zmalloc(sizeof(*state));
state->option_to_line = dictCreate(&optionToLineDictType,NULL);
state->rewritten = dictCreate(&optionSetDictType,NULL);
state->numlines = 0;