From 420068c6e1806a2b12be481abba1afec5d73d82e Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 20 Oct 2013 01:04:55 -0200 Subject: - Fix possible memory leak --- ext/zip/php_zip.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ext/zip/php_zip.c') diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index d7bd5f49e6..df16383d10 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1856,15 +1856,16 @@ static ZIPARCHIVE_METHOD(addFromString) /* TODO: fix _zip_replace */ if (cur_idx >= 0) { if (zip_delete(intern, cur_idx) == -1) { - RETURN_FALSE; + goto fail; } } - if (zip_add(intern, name, zs) == -1) { - RETURN_FALSE; - } else { + if (zip_add(intern, name, zs) != -1) { RETURN_TRUE; } +fail: + zip_source_free(zs); + RETURN_FALSE; } /* }}} */ -- cgit v1.2.1 From 9976b5cd7f36d90b49d1dcf58ec6497f0e592b7d Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 20 Oct 2013 09:50:11 -0200 Subject: - Moved NULL check before dereferencing --- ext/zip/php_zip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/zip/php_zip.c') diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index df16383d10..1f435bbb00 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -102,14 +102,14 @@ static char * php_zip_make_relative_path(char *path, int path_len) /* {{{ */ char *path_begin = path; size_t i; - if (IS_SLASH(path[0])) { - return path + 1; - } - if (path_len < 1 || path == NULL) { return NULL; } + if (IS_SLASH(path[0])) { + return path + 1; + } + i = path_len; while (1) { -- cgit v1.2.1