Revision: 1724
http://vcs.pcre.org/viewvc?view=rev&revision=1724
Author: ph10
Date: 2018-02-19 16:35:05 +0000 (Mon, 19 Feb 2018)
Log Message:
-----------
Fix POSIX API bug when REG_STARTEND is used with a non-zero starting offset and
there are unset groups within the matching group list.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/pcreposix.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2018-01-29 14:45:51 UTC (rev 1723)
+++ code/trunk/ChangeLog 2018-02-19 16:35:05 UTC (rev 1724)
@@ -4,7 +4,7 @@
Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All
development is happening in the PCRE2 10.xx series.
-Version 8.42 xx-xxx-2017
+Version 8.42 xx-xxx-2018
------------------------
1. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard.
@@ -39,7 +39,12 @@
8. Fix out-of-bounds read for partial matching of /./ against an empty string
when the newline type is CRLF.
+9. When matching using the the REG_STARTEND feature of the POSIX API with a
+non-zero starting offset, unset capturing groups with lower numbers than a
+group that did capture something were not being correctly returned as "unset"
+(that is, with offset values of -1).
+
Version 8.41 05-July-2017
-------------------------
Modified: code/trunk/pcreposix.c
===================================================================
--- code/trunk/pcreposix.c 2018-01-29 14:45:51 UTC (rev 1723)
+++ code/trunk/pcreposix.c 2018-02-19 16:35:05 UTC (rev 1724)
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2017 University of Cambridge
+ Copyright (c) 1997-2018 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -389,8 +389,8 @@
{
for (i = 0; i < (size_t)rc; i++)
{
- pmatch[i].rm_so = ovector[i*2] + so;
- pmatch[i].rm_eo = ovector[i*2+1] + so;
+ pmatch[i].rm_so = (ovector[i*2] < 0)? -1 : ovector[i*2] + so;
+ pmatch[i].rm_eo = (ovector[i*2+1] < 0)? -1: ovector[i*2+1] + so;
}
if (allocated_ovector) free(ovector);
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;