Ticket #6545 (new defect)

SVN Diffs for #6545

 

Opened 1 year ago

Last modified 1 year ago

uregex_reset(icu_regex, 0, &status) returns an error #8, U_INDEX_OUTOFBOUNDS_ERROR when the string to scan has a length of zero

Reported by: john.engelhart@... Assigned to: andy
Priority: assess Milestone: UNSCH
Component: regexp Version: 3.8.1
Keywords: Cc:
Load: Xref:
Java Version: Operating System:
Project (C/J): ICU4C Weeks:
Review:

Description

The problem is really in RegexMatcher &RegexMatcher::reset(int32_t position, UErrorCode &status), specifically the following piece of code in it:

if (position < 0 position >= fInput->length()) {

status = U_INDEX_OUTOFBOUNDS_ERROR; return *this;

}

The position check should be "> Greater Than", not ">= Greater Than or Equal". This is obviously a problem for zero-length strings (ie, ""), since there is no way to reset them.

This in turn causes problems with the likes of uregex_replaceAll(), as it performs "uregex_reset(regexp, 0, status);". Consider the example where the string to scan has a length of zero, with a regex of "$". Now, calling uregex_replaceAll() with a replacement string of "REPLACED" should work, since "$" matches the end of the string. This can't happen, however, since uregex_reset incorrectly reports an error via status.

Attachments

Change History

09/24/08 10:36:18 changed by yoshito

  • owner changed from somebody to andy.
  • weeks changed.
  • xref changed.
  • revw changed.

Add/Change #6545 (uregex_reset(icu_regex, 0, &status) returns an error #8, U_INDEX_OUTOFBOUNDS_ERROR when the string to scan has a length of zero)




Anti spam check: