From 736da4bfb96afa8ba368e1fdee016e9cb0f84da1 Mon Sep 17 00:00:00 2001 From: chris mikkelson Date: Sat, 13 Mar 2010 12:03:33 -0600 Subject: [PATCH] Fix usage of pcre_copy_substring -- return value of pcre_exec is not usable as the stringcount if match is PCRE_ERROR_PARTIAL. --- re_stream.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; -- 2.50.1