com php-src: Improves fix for memory leak, keep in sync with upstream.: ext/fileinfo/libmagic/softmagic.c
| From: | Remi Collet | Date: | Tue, 04 Mar 2014 12:41:37 +0000 |
| Subject: | com php-src: Improves fix for memory leak, keep in sync with upstream.: ext/fileinfo/libmagic/softmagic.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76320@lists.php.net to get a copy of this message | ||
Commit: 731013ee8e9cf405101d4fd584214fadb1c1d390
Author: Remi Collet <remi@php.net> Tue, 4 Mar 2014 13:41:37 +0100
Parents: 1533f98afddee259444c00a2dea86029002e5cf7
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=731013ee8e9cf405101d4fd584214fadb1c1d390
Log:
Improves fix for memory leak, keep in sync with upstream.
Previous fix:
http://git.php.net/?p=php-src.git;a=commitdiff;h=10eb0070700382f966bf260e44135e1f724a15d2
Upstream fix:
https://github.com/glensc/file/commit/c0c0032b9e9eb57b91fefef905a3b018bab492d9
Changed paths:
M ext/fileinfo/libmagic/softmagic.c
Diff:
diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c
index 33970e5..82a470a 100644
--- a/ext/fileinfo/libmagic/softmagic.c
+++ b/ext/fileinfo/libmagic/softmagic.c
@@ -1696,11 +1696,19 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
ms->o.buf = sbuf;
ms->offset = soffset;
if (rv == 1) {
- if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
- file_printf(ms, m->desc, offset) == -1)
- return -1;
- if (file_printf(ms, "%s", rbuf) == -1)
+ if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
+ file_printf(ms, m->desc, offset) == -1) {
+ if (rbuf) {
+ efree(rbuf);
+ }
+ return -1;
+ }
+ if (file_printf(ms, "%s", rbuf) == -1) {
+ if (rbuf) {
+ efree(rbuf);
+ }
return -1;
+ }
}
if (rbuf) {
efree(rbuf);