--- code/trunk/pcre_exec.c 2010/05/29 15:50:39 527 +++ code/trunk/pcre_exec.c 2010/06/03 18:26:05 534 @@ -295,6 +295,7 @@ #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\ {\ heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\ + if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\ frame->Xwhere = rw; \ newframe->Xeptr = ra;\ newframe->Xecode = rb;\ @@ -488,6 +489,7 @@ #ifdef NO_RECURSE heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe)); +if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY); frame->Xprevframe = NULL; /* Marks the top level */ /* Copy in the original argument variables */ @@ -794,7 +796,8 @@ save_capture_last = md->capture_last; DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3)); - md->offset_vector[md->offset_end - number] = eptr - md->start_subject; + md->offset_vector[md->offset_end - number] = + (int)(eptr - md->start_subject); flags = (op == OP_SCBRA)? match_cbegroup : 0; do @@ -889,9 +892,9 @@ cb.callout_number = ecode[LINK_SIZE+2]; cb.offset_vector = md->offset_vector; cb.subject = (PCRE_SPTR)md->start_subject; - cb.subject_length = md->end_subject - md->start_subject; - cb.start_match = mstart - md->start_subject; - cb.current_position = eptr - md->start_subject; + cb.subject_length = (int)(md->end_subject - md->start_subject); + cb.start_match = (int)(mstart - md->start_subject); + cb.current_position = (int)(eptr - md->start_subject); cb.pattern_position = GET(ecode, LINK_SIZE + 3); cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE); cb.capture_top = offset_top/2; @@ -1117,7 +1120,7 @@ { md->offset_vector[offset] = md->offset_vector[md->offset_end - number]; - md->offset_vector[offset+1] = eptr - md->start_subject; + md->offset_vector[offset+1] = (int)(eptr - md->start_subject); if (offset_top <= offset) offset_top = offset + 2; } ecode += 3; @@ -1280,9 +1283,9 @@ cb.callout_number = ecode[1]; cb.offset_vector = md->offset_vector; cb.subject = (PCRE_SPTR)md->start_subject; - cb.subject_length = md->end_subject - md->start_subject; - cb.start_match = mstart - md->start_subject; - cb.current_position = eptr - md->start_subject; + cb.subject_length = (int)(md->end_subject - md->start_subject); + cb.start_match = (int)(mstart - md->start_subject); + cb.current_position = (int)(eptr - md->start_subject); cb.pattern_position = GET(ecode, 2); cb.next_item_length = GET(ecode, 2 + LINK_SIZE); cb.capture_top = offset_top/2; @@ -1559,7 +1562,7 @@ { md->offset_vector[offset] = md->offset_vector[md->offset_end - number]; - md->offset_vector[offset+1] = eptr - md->start_subject; + md->offset_vector[offset+1] = (int)(eptr - md->start_subject); if (offset_top <= offset) offset_top = offset + 2; } @@ -2233,7 +2236,7 @@ referenced subpattern. */ if (offset >= offset_top || md->offset_vector[offset] < 0) - length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1; + length = (md->jscript_compat)? 0 : (int)(md->end_subject - eptr + 1); else length = md->offset_vector[offset+1] - md->offset_vector[offset]; @@ -4213,7 +4216,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); if (prop_fail_result) MRRETURN(MATCH_NOMATCH); } /* Control never gets here */ @@ -4229,7 +4232,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_chartype = UCD_CHARTYPE(c); if ((prop_chartype == ucp_Lu || prop_chartype == ucp_Ll || @@ -4249,7 +4252,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_category = UCD_CATEGORY(c); if ((prop_category == prop_value) == prop_fail_result) MRRETURN(MATCH_NOMATCH); @@ -4267,7 +4270,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_chartype = UCD_CHARTYPE(c); if ((prop_chartype == prop_value) == prop_fail_result) MRRETURN(MATCH_NOMATCH); @@ -4285,7 +4288,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_script = UCD_SCRIPT(c); if ((prop_script == prop_value) == prop_fail_result) MRRETURN(MATCH_NOMATCH); @@ -4303,7 +4306,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_L || prop_category == ucp_N) == prop_fail_result) @@ -4322,7 +4325,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR) @@ -4342,7 +4345,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) @@ -4362,7 +4365,7 @@ SCHECK_PARTIAL(); MRRETURN(MATCH_NOMATCH); } - GETCHARINC(c, eptr); + GETCHARINCTEST(c, eptr); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_L || prop_category == ucp_N || @@ -4720,7 +4723,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); if (prop_fail_result) break; eptr+= len; } @@ -4735,7 +4738,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_chartype = UCD_CHARTYPE(c); if ((prop_chartype == ucp_Lu || prop_chartype == ucp_Ll || @@ -4754,7 +4757,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_category = UCD_CATEGORY(c); if ((prop_category == prop_value) == prop_fail_result) break; @@ -4771,7 +4774,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_chartype = UCD_CHARTYPE(c); if ((prop_chartype == prop_value) == prop_fail_result) break; @@ -4788,7 +4791,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_script = UCD_SCRIPT(c); if ((prop_script == prop_value) == prop_fail_result) break; @@ -4805,7 +4808,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_L || prop_category == ucp_N) == prop_fail_result) @@ -4823,7 +4826,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR) @@ -4842,7 +4845,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL || c == CHAR_VT || c == CHAR_FF || c == CHAR_CR) @@ -4861,7 +4864,7 @@ SCHECK_PARTIAL(); break; } - GETCHARLEN(c, eptr, len); + GETCHARLENTEST(c, eptr, len); prop_category = UCD_CATEGORY(c); if ((prop_category == ucp_L || prop_category == ucp_N || c == CHAR_UNDERSCORE) == prop_fail_result) @@ -6176,8 +6179,8 @@ if (offsetcount < 2) rc = 0; else { - offsets[0] = md->start_match_ptr - md->start_subject; - offsets[1] = md->end_match_ptr - md->start_subject; + offsets[0] = (int)(md->start_match_ptr - md->start_subject); + offsets[1] = (int)(md->end_match_ptr - md->start_subject); } DPRINTF((">>>> returning %d\n", rc)); @@ -6209,8 +6212,8 @@ md->mark = NULL; if (offsetcount > 1) { - offsets[0] = start_partial - (USPTR)subject; - offsets[1] = end_subject - (USPTR)subject; + offsets[0] = (int)(start_partial - (USPTR)subject); + offsets[1] = (int)(end_subject - (USPTR)subject); } rc = PCRE_ERROR_PARTIAL; }