Skip to content

Commit efa9a9f

Browse files
committed
fix double free
Signed-off-by: Ray Cao <zisong.cw@alibaba-inc.com>
1 parent 8660183 commit efa9a9f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/aof.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ int RestartAOFWithSyncFile(void) {
10441044
new_incr_filepath = makePath(server.aof_dirname, new_incr_filename);
10451045
newfd = open(new_incr_filepath, O_WRONLY | O_TRUNC | O_CREAT, 0644);
10461046
sdsfree(new_incr_filepath);
1047+
new_incr_filepath = NULL;
10471048
if (newfd == -1) {
10481049
serverLog(LL_WARNING, "Can't open the append-only file %s: %s", new_incr_filename, strerror(errno));
10491050
goto cleanup;
@@ -1065,6 +1066,7 @@ int RestartAOFWithSyncFile(void) {
10651066

10661067
/* Now, it will not goto clean up, then we can safely free new_base_filepath */
10671068
sdsfree(new_base_filepath);
1069+
new_base_filepath = NULL;
10681070

10691071
/* Set the initial repl_offset, which will be applied to fsynced_reploff */
10701072
atomic_store_explicit(&server.fsynced_reploff_pending, server.primary_repl_offset, memory_order_relaxed);

0 commit comments

Comments
 (0)