Skip to content

Commit

Permalink
Revert "libmagic: Move the allocation on the stack"
Browse files Browse the repository at this point in the history
This reverts commit 1d84a58.

Signed-off-by: Anatol Belski <ab@php.net>
  • Loading branch information
weltling committed Sep 2, 2020
1 parent f3f5719 commit f2b4077
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ext/fileinfo/libmagic/softmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,11 @@ check_fmt(struct magic_set *ms, const char *fmt)
pcre_cache_entry *pce;
int rv = -1;
zend_string *pattern;
ALLOCA_FLAG(use_heap)

if (strchr(fmt, '%') == NULL)
return 0;

ZSTR_ALLOCA_INIT(pattern, "~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, use_heap);
pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0);
if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) {
rv = -1;
} else {
Expand All @@ -495,7 +494,7 @@ check_fmt(struct magic_set *ms, const char *fmt)
php_pcre_free_match_data(match_data);
}
}
ZSTR_ALLOCA_FREE(pattern, use_heap);
zend_string_release(pattern);
return rv;
}

Expand Down

0 comments on commit f2b4077

Please sign in to comment.