]> git.mikk.net Git - liburl/commitdiff
Fix usage of pcre_copy_substring -- return value of pcre_exec is not
authorchris mikkelson <chris@mikk.net>
Sat, 13 Mar 2010 18:03:33 +0000 (12:03 -0600)
committerchris mikkelson <chris@mikk.net>
Sat, 13 Mar 2010 18:03:33 +0000 (12:03 -0600)
usable as the stringcount if match is PCRE_ERROR_PARTIAL.

re_stream.c

index 4a57355c0abc8500d36dcc3d6050f789e4d5b614..dec92f0aadde189f569b3875dcb8d515a43c541b 100644 (file)
@@ -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;