More refactoring for ovector addressing.

This commit is contained in:
Philip.Hazel 2017-05-11 16:49:58 +00:00
parent cd4a219626
commit 67995268cf
3 changed files with 8 additions and 10 deletions

View File

@ -637,7 +637,11 @@ typedef struct pcre2_real_code {
uint16_t name_count; /* Number of name entries in the table */ uint16_t name_count; /* Number of name entries in the table */
} pcre2_real_code; } 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 { typedef struct pcre2_real_match_data {
pcre2_memctl memctl; pcre2_memctl memctl;
@ -650,7 +654,7 @@ typedef struct pcre2_real_match_data {
uint16_t matchedby; /* Type of match (normal, JIT, DFA) */ uint16_t matchedby; /* Type of match (normal, JIT, DFA) */
uint16_t oveccount; /* Number of pairs */ uint16_t oveccount; /* Number of pairs */
int rc; /* The return code from the match */ 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; } pcre2_real_match_data;

View File

@ -182,14 +182,8 @@ of use and undefined afterwards. */
#define Foffset_top F->offset_top #define Foffset_top F->offset_top
#define Foccu F->occu #define Foccu F->occu
#define Fop F->op #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 Fovector F->ovector
#define Freturn_id F->return_id
#ifdef DEBUG_FRAMES_DISPLAY #ifdef DEBUG_FRAMES_DISPLAY

View File

@ -59,7 +59,7 @@ pcre2_match_data_create(uint32_t oveccount, pcre2_general_context *gcontext)
pcre2_match_data *yield; pcre2_match_data *yield;
if (oveccount < 1) oveccount = 1; if (oveccount < 1) oveccount = 1;
yield = PRIV(memctl_malloc)( 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); (pcre2_memctl *)gcontext);
if (yield == NULL) return NULL; if (yield == NULL) return NULL;
yield->oveccount = oveccount; yield->oveccount = oveccount;