From: chris mikkelson Date: Sat, 13 Mar 2010 18:03:33 +0000 (-0600) Subject: Fix usage of pcre_copy_substring -- return value of pcre_exec is not X-Git-Url: https://git.mikk.net/?a=commitdiff_plain;h=736da4bfb96afa8ba368e1fdee016e9cb0f84da1;p=liburl Fix usage of pcre_copy_substring -- return value of pcre_exec is not usable as the stringcount if match is PCRE_ERROR_PARTIAL. --- diff --git a/re_stream.c b/re_stream.c index 4a57355..dec92f0 100644 --- a/re_stream.c +++ b/re_stream.c @@ -59,7 +59,7 @@ re_stream_result(struct stream_re *sre) int re_stream_exec(struct stream_re *sre, char *sub, int slen) { - int match, flags, newlen, start, end; + int match, strcount, flags, newlen, start, end; if (sre->state == -1) { flags = PCRE_PARTIAL | PCRE_DFA_RESTART; @@ -105,7 +105,10 @@ re_stream_exec(struct stream_re *sre, char *sub, int slen) sre->result = reallocf(sre->result, sre->ralloc); if (!sre->result) return -1; } - pcre_copy_substring(sub, sre->ovec, match, 0, + + strcount = match; + if (match == PCRE_ERROR_PARTIAL) strcount = 1; + pcre_copy_substring(sub, sre->ovec, strcount, 0, sre->result + sre->rlen, sre->ralloc - sre->rlen); sre->rlen = newlen;