X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/2acb89982f71719aec26ca16705bd2c0400a9550..refs/heads/master:/regex/TRE/lib/regexec.c diff --git a/regex/TRE/lib/regexec.c b/regex/TRE/lib/regexec.c index 6823f72..174f6b6 100644 --- a/regex/TRE/lib/regexec.c +++ b/regex/TRE/lib/regexec.c @@ -205,7 +205,7 @@ tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags, i++; } #ifndef TRE_USE_ALLOCA - if (tags != intags) xfree(tags); + if (tags != intags) xfree((void*)tags); #endif /* !TRE_USE_ALLOCA */ } @@ -251,16 +251,6 @@ tre_match(const tre_tnfa_t *tnfa, const void *string, size_t len, tre_tag_t *tags = NULL; int eo; size_t offset = 0, count = 0; - if (tnfa->num_tags > 0 && nmatch > 0) - { -#ifdef TRE_USE_ALLOCA - tags = alloca(sizeof(*tags) * tnfa->num_tags); -#else /* !TRE_USE_ALLOCA */ - tags = xmalloc(sizeof(*tags) * tnfa->num_tags); -#endif /* !TRE_USE_ALLOCA */ - if (tags == NULL) - return REG_ESPACE; - } if ( #ifdef TRE_STR_USER @@ -280,6 +270,17 @@ tre_match(const tre_tnfa_t *tnfa, const void *string, size_t len, if (type == STR_WIDE) offset *= sizeof(wchar_t); } + if (tnfa->num_tags > 0 && nmatch > 0) + { +#ifdef TRE_USE_ALLOCA + tags = alloca(sizeof(*tags) * tnfa->num_tags); +#else /* !TRE_USE_ALLOCA */ + tags = xmalloc(sizeof(*tags) * tnfa->num_tags); +#endif /* !TRE_USE_ALLOCA */ + if (tags == NULL) + return REG_ESPACE; + } + /* Dispatch to the appropriate matcher. */ if (tnfa->have_backrefs || eflags & REG_BACKTRACKING_MATCHER) { @@ -291,8 +292,8 @@ tre_match(const tre_tnfa_t *tnfa, const void *string, size_t len, if (source->rewind == NULL || source->compare == NULL) /* The backtracking matcher requires rewind and compare capabilities from the input stream. */ - return REG_BADPAT; - } + status = REG_BADPAT; + } else #endif /* TRE_STR_USER */ status = tre_tnfa_run_backtrack(tnfa, string + offset, (int)len, type, tags, eflags, &eo);