From 4dc1b2b0cda79b3a517f2e192e7d9fe8c0363912 Mon Sep 17 00:00:00 2001 From: gogolovefish <64474767+gogolovefish@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:46:19 +0800 Subject: [PATCH] Update gzlog.c fix memory leak --- deps/zlib/examples/gzlog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deps/zlib/examples/gzlog.c b/deps/zlib/examples/gzlog.c index b8c29274e..d830ddf04 100644 --- a/deps/zlib/examples/gzlog.c +++ b/deps/zlib/examples/gzlog.c @@ -757,12 +757,15 @@ local int log_recover(struct log *log, int op) } if ((fd = open(log->path, O_RDONLY, 0)) < 0) { log_log(log, op, ".add file read failure"); + if (data != NULL) + free(data); return -1; } ret = (size_t)read(fd, data, len) != len; close(fd); if (ret) { log_log(log, op, ".add file read failure"); + return -1; } log_log(log, op, "loaded .add file");