summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2017-05-11 16:49:58 +0000
committerph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>2017-05-11 16:49:58 +0000
commit89c86560874a8cfa422be7d2b22d18ed6e20635e (patch)
tree028f9ae6692ee1e43498f2c8bd26cf7455671e80
parent25aebdd07fb4de49d00d037586fb1770177662cc (diff)
downloadpcre2-89c86560874a8cfa422be7d2b22d18ed6e20635e.tar.gz
More refactoring for ovector addressing.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@780 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r--src/pcre2_intmodedep.h8
-rw-r--r--src/pcre2_match.c8
-rw-r--r--src/pcre2_match_data.c2
3 files changed, 8 insertions, 10 deletions
diff --git a/src/pcre2_intmodedep.h b/src/pcre2_intmodedep.h
index 6bc9c09..a05f312 100644
--- a/src/pcre2_intmodedep.h
+++ b/src/pcre2_intmodedep.h
@@ -637,7 +637,11 @@ typedef struct pcre2_real_code {
uint16_t name_count; /* Number of name entries in the table */
} pcre2_real_code;
-/* The real match data structure. */
+/* The real match data structure. Define ovector large so that array bound
+checkers don't grumble. Memory for this structure is obtained by calling
+pcre2_match_data_create(), which sets the size as the offset of ovector plus
+pairs of elements for each capturing group. (See also the heapframe structure
+below.) */
typedef struct pcre2_real_match_data {
pcre2_memctl memctl;
@@ -650,7 +654,7 @@ typedef struct pcre2_real_match_data {
uint16_t matchedby; /* Type of match (normal, JIT, DFA) */
uint16_t oveccount; /* Number of pairs */
int rc; /* The return code from the match */
- PCRE2_SIZE ovector[1]; /* The first field */
+ PCRE2_SIZE ovector[10000];/* The first field */
} pcre2_real_match_data;
diff --git a/src/pcre2_match.c b/src/pcre2_match.c
index 87def5e..a3399f1 100644
--- a/src/pcre2_match.c
+++ b/src/pcre2_match.c
@@ -182,14 +182,8 @@ of use and undefined afterwards. */
#define Foffset_top F->offset_top
#define Foccu F->occu
#define Fop F->op
-#define Freturn_id F->return_id
-
-/* We need a cast for this one because F->ovector is a vector of size 2, at the
-end of the backtrack frame, but when there are capturing parentheses the space
-allocated is bigger so we want to be able to address more elements. Without the
-case, -fsanitize=undefined grumbles at this. */
-
#define Fovector F->ovector
+#define Freturn_id F->return_id
#ifdef DEBUG_FRAMES_DISPLAY
diff --git a/src/pcre2_match_data.c b/src/pcre2_match_data.c
index 4dd9668..b297f32 100644
--- a/src/pcre2_match_data.c
+++ b/src/pcre2_match_data.c
@@ -59,7 +59,7 @@ pcre2_match_data_create(uint32_t oveccount, pcre2_general_context *gcontext)
pcre2_match_data *yield;
if (oveccount < 1) oveccount = 1;
yield = PRIV(memctl_malloc)(
- sizeof(pcre2_match_data) + 2*oveccount*sizeof(PCRE2_SIZE),
+ offsetof(pcre2_match_data, ovector) + 2*oveccount*sizeof(PCRE2_SIZE),
(pcre2_memctl *)gcontext);
if (yield == NULL) return NULL;
yield->oveccount = oveccount;