@@ -7012,9 +7012,11 @@ if (subject == NULL && length == 0) subject = null_str;
70127012
70137013/* Plausibility checks */
70147014
7015- if ((options & ~PUBLIC_MATCH_OPTIONS ) != 0 ) return PCRE2_ERROR_BADOPTION ;
7016- if (code == NULL || subject == NULL || match_data == NULL )
7017- return PCRE2_ERROR_NULL ;
7015+ if (match_data == NULL ) return PCRE2_ERROR_NULL ;
7016+ if (code == NULL || subject == NULL )
7017+ return match_data -> rc = PCRE2_ERROR_NULL ;
7018+ if ((options & ~PUBLIC_MATCH_OPTIONS ) != 0 )
7019+ return match_data -> rc = PCRE2_ERROR_BADOPTION ;
70187020
70197021start_match = subject + start_offset ;
70207022req_cu_ptr = start_match - 1 ;
@@ -7025,16 +7027,17 @@ if (length == PCRE2_ZERO_TERMINATED)
70257027 }
70267028true_end_subject = end_subject = subject + length ;
70277029
7028- if (start_offset > length ) return PCRE2_ERROR_BADOFFSET ;
7030+ if (start_offset > length ) return match_data -> rc = PCRE2_ERROR_BADOFFSET ;
70297031
70307032/* Check that the first field in the block is the magic number. */
70317033
7032- if (re -> magic_number != MAGIC_NUMBER ) return PCRE2_ERROR_BADMAGIC ;
7034+ if (re -> magic_number != MAGIC_NUMBER )
7035+ return match_data -> rc = PCRE2_ERROR_BADMAGIC ;
70337036
70347037/* Check the code unit width. */
70357038
70367039if ((re -> flags & PCRE2_MODE_MASK ) != PCRE2_CODE_UNIT_WIDTH /8 )
7037- return PCRE2_ERROR_BADMODE ;
7040+ return match_data -> rc = PCRE2_ERROR_BADMODE ;
70387041
70397042/* PCRE2_NOTEMPTY and PCRE2_NOTEMPTY_ATSTART are match-time flags in the
70407043options variable for this function. Users of PCRE2 who are not calling the
@@ -7081,14 +7084,14 @@ time. */
70817084
70827085if (mb -> partial != 0 &&
70837086 ((re -> overall_options | options ) & PCRE2_ENDANCHORED ) != 0 )
7084- return PCRE2_ERROR_BADOPTION ;
7087+ return match_data -> rc = PCRE2_ERROR_BADOPTION ;
70857088
70867089/* It is an error to set an offset limit without setting the flag at compile
70877090time. */
70887091
70897092if (mcontext != NULL && mcontext -> offset_limit != PCRE2_UNSET &&
70907093 (re -> overall_options & PCRE2_USE_OFFSET_LIMIT ) == 0 )
7091- return PCRE2_ERROR_BADOFFSETLIMIT ;
7094+ return match_data -> rc = PCRE2_ERROR_BADOFFSETLIMIT ;
70927095
70937096/* If the match data block was previously used with PCRE2_COPY_MATCHED_SUBJECT,
70947097free the memory that was obtained. Set the field to NULL for no match cases. */
@@ -7128,11 +7131,11 @@ if (use_jit)
71287131#if PCRE2_CODE_UNIT_WIDTH != 32
71297132 if (start_match < end_subject && NOT_FIRSTCU (* start_match ))
71307133 {
7131- if (start_offset > 0 ) return PCRE2_ERROR_BADUTFOFFSET ;
7134+ if (start_offset > 0 ) return match_data -> rc = PCRE2_ERROR_BADUTFOFFSET ;
71327135#if PCRE2_CODE_UNIT_WIDTH == 8
7133- return PCRE2_ERROR_UTF8_ERR20 ; /* Isolated 0x80 byte */
7136+ return match_data -> rc = PCRE2_ERROR_UTF8_ERR20 ; /* Isolated 0x80 byte */
71347137#else
7135- return PCRE2_ERROR_UTF16_ERR3 ; /* Isolated low surrogate */
7138+ return match_data -> rc = PCRE2_ERROR_UTF16_ERR3 ; /* Isolated low surrogate */
71367139#endif
71377140 }
71387141#endif /* WIDTH != 32 */
@@ -7167,12 +7170,12 @@ if (use_jit)
71677170 /* Validate the relevant portion of the subject. Adjust the offset of an
71687171 invalid code point to be an absolute offset in the whole string. */
71697172
7170- match_data -> rc = PRIV (valid_utf )(start_match ,
7173+ rc = PRIV (valid_utf )(start_match ,
71717174 length - (start_match - subject ), & (match_data -> startchar ));
7172- if (match_data -> rc != 0 )
7175+ if (rc != 0 )
71737176 {
71747177 match_data -> startchar += start_match - subject ;
7175- return match_data -> rc ;
7178+ return match_data -> rc = rc ;
71767179 }
71777180 jit_checked_utf = TRUE;
71787181 }
@@ -7190,7 +7193,8 @@ if (use_jit)
71907193 length = CU2BYTES (length + was_zero_terminated );
71917194 match_data -> subject = match_data -> memctl .malloc (length ,
71927195 match_data -> memctl .memory_data );
7193- if (match_data -> subject == NULL ) return PCRE2_ERROR_NOMEMORY ;
7196+ if (match_data -> subject == NULL )
7197+ return match_data -> rc = PCRE2_ERROR_NOMEMORY ;
71947198 memcpy ((void * )match_data -> subject , subject , length );
71957199 match_data -> flags |= PCRE2_MD_COPIED_SUBJECT ;
71967200 }
@@ -7256,11 +7260,11 @@ if (utf &&
72567260 }
72577261 else if (start_match < end_subject && NOT_FIRSTCU (* start_match ))
72587262 {
7259- if (start_offset > 0 ) return PCRE2_ERROR_BADUTFOFFSET ;
7263+ if (start_offset > 0 ) return match_data -> rc = PCRE2_ERROR_BADUTFOFFSET ;
72607264#if PCRE2_CODE_UNIT_WIDTH == 8
7261- return PCRE2_ERROR_UTF8_ERR20 ; /* Isolated 0x80 byte */
7265+ return match_data -> rc = PCRE2_ERROR_UTF8_ERR20 ; /* Isolated 0x80 byte */
72627266#else
7263- return PCRE2_ERROR_UTF16_ERR3 ; /* Isolated low surrogate */
7267+ return match_data -> rc = PCRE2_ERROR_UTF16_ERR3 ; /* Isolated low surrogate */
72647268#endif
72657269 }
72667270#endif /* WIDTH != 32 */
@@ -7308,18 +7312,18 @@ if (utf &&
73087312
73097313 for (;;)
73107314 {
7311- match_data -> rc = PRIV (valid_utf )(mb -> check_subject ,
7315+ rc = PRIV (valid_utf )(mb -> check_subject ,
73127316 length - (mb -> check_subject - subject ), & (match_data -> startchar ));
73137317
7314- if (match_data -> rc == 0 ) break ; /* Valid UTF string */
7318+ if (rc == 0 ) break ; /* Valid UTF string */
73157319
73167320 /* Invalid UTF string. Adjust the offset to be an absolute offset in the
73177321 whole string. If we are handling invalid UTF strings, set end_subject to
73187322 stop before the bad code unit, and set the options to "not end of line".
73197323 Otherwise return the error. */
73207324
73217325 match_data -> startchar += mb -> check_subject - subject ;
7322- if (!allow_invalid || match_data -> rc > 0 ) return match_data -> rc ;
7326+ if (!allow_invalid || rc > 0 ) return match_data -> rc = rc ;
73237327 end_subject = subject + match_data -> startchar ;
73247328
73257329 /* If the end precedes start_match, it means there is invalid UTF in the
@@ -7436,7 +7440,7 @@ switch(re->newline_convention)
74367440 /* LCOV_EXCL_START */
74377441 default :
74387442 PCRE2_DEBUG_UNREACHABLE ();
7439- return PCRE2_ERROR_INTERNAL ;
7443+ return match_data -> rc = PCRE2_ERROR_INTERNAL ;
74407444 /* LCOV_EXCL_STOP */
74417445 }
74427446
@@ -7479,7 +7483,7 @@ if (heapframes_size < START_FRAMES_SIZE) heapframes_size = START_FRAMES_SIZE;
74797483if (heapframes_size / 1024 > mb -> heap_limit )
74807484 {
74817485 PCRE2_SIZE max_size = 1024 * mb -> heap_limit ;
7482- if (max_size < frame_size ) return PCRE2_ERROR_HEAPLIMIT ;
7486+ if (max_size < frame_size ) return match_data -> rc = PCRE2_ERROR_HEAPLIMIT ;
74837487 heapframes_size = max_size ;
74847488 }
74857489
@@ -7495,7 +7499,7 @@ if (match_data->heapframes_size < heapframes_size)
74957499 if (match_data -> heapframes == NULL )
74967500 {
74977501 match_data -> heapframes_size = 0 ;
7498- return PCRE2_ERROR_NOMEMORY ;
7502+ return match_data -> rc = PCRE2_ERROR_NOMEMORY ;
74997503 }
75007504 match_data -> heapframes_size = heapframes_size ;
75017505 }
@@ -8150,7 +8154,8 @@ if (rc == MATCH_MATCH)
81508154 length = CU2BYTES (length + was_zero_terminated );
81518155 match_data -> subject = match_data -> memctl .malloc (length ,
81528156 match_data -> memctl .memory_data );
8153- if (match_data -> subject == NULL ) return PCRE2_ERROR_NOMEMORY ;
8157+ if (match_data -> subject == NULL )
8158+ return match_data -> rc = PCRE2_ERROR_NOMEMORY ;
81548159 memcpy ((void * )match_data -> subject , subject , length );
81558160 match_data -> flags |= PCRE2_MD_COPIED_SUBJECT ;
81568161 }
0 commit comments