diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2019-05-25 22:23:20 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2019-05-25 22:23:20 -0700 |
| commit | 02064366155215162223417b939deebfe563ded0 (patch) | |
| tree | d85c328da9b21793632fcdb088216a2089bb97ff /examples | |
| parent | 79baebe50e4d6b73ae1f8b603f0ef41300110aa3 (diff) | |
| download | zlib-02064366155215162223417b939deebfe563ded0.tar.gz zlib-02064366155215162223417b939deebfe563ded0.tar.bz2 zlib-02064366155215162223417b939deebfe563ded0.zip | |
Fix memory leak on error in gzlog.c.
Thank you Adam Richter.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/gzlog.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/gzlog.c b/examples/gzlog.c index b8c2927..b977802 100644 --- a/examples/gzlog.c +++ b/examples/gzlog.c | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * gzlog.c | 2 | * gzlog.c |
| 3 | * Copyright (C) 2004, 2008, 2012, 2016 Mark Adler, all rights reserved | 3 | * Copyright (C) 2004, 2008, 2012, 2016, 2019 Mark Adler, all rights reserved |
| 4 | * For conditions of distribution and use, see copyright notice in gzlog.h | 4 | * For conditions of distribution and use, see copyright notice in gzlog.h |
| 5 | * version 2.2, 14 Aug 2012 | 5 | * version 2.3, 25 May 2019 |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | /* | 8 | /* |
| @@ -756,12 +756,14 @@ local int log_recover(struct log *log, int op) | |||
| 756 | return -2; | 756 | return -2; |
| 757 | } | 757 | } |
| 758 | if ((fd = open(log->path, O_RDONLY, 0)) < 0) { | 758 | if ((fd = open(log->path, O_RDONLY, 0)) < 0) { |
| 759 | free(data); | ||
| 759 | log_log(log, op, ".add file read failure"); | 760 | log_log(log, op, ".add file read failure"); |
| 760 | return -1; | 761 | return -1; |
| 761 | } | 762 | } |
| 762 | ret = (size_t)read(fd, data, len) != len; | 763 | ret = (size_t)read(fd, data, len) != len; |
| 763 | close(fd); | 764 | close(fd); |
| 764 | if (ret) { | 765 | if (ret) { |
| 766 | free(data); | ||
| 765 | log_log(log, op, ".add file read failure"); | 767 | log_log(log, op, ".add file read failure"); |
| 766 | return -1; | 768 | return -1; |
| 767 | } | 769 | } |
