Skip to content

Commit e7fa402

Browse files
committed
Bug #61504 TSRML_FETCH() must be last
1 parent 0676031 commit e7fa402

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

ext/fileinfo/libmagic/funcs.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
435435
{
436436
zval *patt;
437437
int opts = 0;
438-
TSRMLS_FETCH();
439438
pcre_cache_entry *pce;
440439
char *res;
441440
zval *repl;
442441
int res_len, rep_cnt;
442+
TSRMLS_FETCH();
443443

444444
MAKE_STD_ZVAL(patt);
445445
ZVAL_STRINGL(patt, pat, strlen(pat), 0);
@@ -477,31 +477,3 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
477477
return rep_cnt;
478478
}
479479

480-
#if 0
481-
protected int
482-
file_replace(struct magic_set *ms, const char *pat, const char *rep)
483-
{
484-
regex_t rx;
485-
int rc;
486-
487-
rc = regcomp(&rx, pat, REG_EXTENDED);
488-
if (rc) {
489-
char errmsg[512];
490-
(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
491-
file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
492-
return -1;
493-
} else {
494-
regmatch_t rm;
495-
int nm = 0;
496-
while (regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) {
497-
ms->o.buf[rm.rm_so] = '\0';
498-
if (file_printf(ms, "%s%s", rep,
499-
rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1)
500-
return -1;
501-
nm++;
502-
}
503-
regfree(&rx);
504-
return nm;
505-
}
506-
}
507-
#endif

0 commit comments

Comments
 (0)