Skip to content

Commit bc0b6e0

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Improves fix for memory leak, keep in sync with upstream.
2 parents c34f26a + 731013e commit bc0b6e0

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ext/fileinfo/libmagic/softmagic.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,11 +1696,19 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
16961696
ms->o.buf = sbuf;
16971697
ms->offset = soffset;
16981698
if (rv == 1) {
1699-
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
1700-
file_printf(ms, m->desc, offset) == -1)
1701-
return -1;
1702-
if (file_printf(ms, "%s", rbuf) == -1)
1699+
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
1700+
file_printf(ms, m->desc, offset) == -1) {
1701+
if (rbuf) {
1702+
efree(rbuf);
1703+
}
1704+
return -1;
1705+
}
1706+
if (file_printf(ms, "%s", rbuf) == -1) {
1707+
if (rbuf) {
1708+
efree(rbuf);
1709+
}
17031710
return -1;
1711+
}
17041712
}
17051713
if (rbuf) {
17061714
efree(rbuf);

0 commit comments

Comments
 (0)