Changeset 2304 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp


Ignore:
Timestamp:
Oct 10, 2002, 9:07:07 PM (23 years ago)
Author:
darin
Message:
  • fixed 3072643 -- infinite loop in JavaScript code at walgreens.com

The problem is that "xxx".indexOf("", 1) needs to return 1, but we
were returning 0.

  • kjs/ustring.cpp: (UString::find): Return pos, not 0, when the search string is empty. (UString::rfind): Make sure that pos is not past the end of the string, taking into account the search string; fixes a potential read off the end of the buffer. Also return pos, not 0, when the search string is empty.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r1887 r2304  
    492492  if (sz < fsz)
    493493    return -1;
    494   if (fsz == 0)
    495     return 0;
    496494  if (pos < 0)
    497495    pos = 0;
     496  if (fsz == 0)
     497    return pos;
    498498  const UChar *end = data() + sz - fsz;
    499499  long fsizeminusone = (fsz - 1) * sizeof(UChar);
     
    524524  if (sz < fsz)
    525525    return -1;
    526   if (fsz == 0)
    527     return 0;
    528526  if (pos < 0)
    529527    pos = 0;
     528  if (pos > sz - fsz)
     529    pos = sz - fsz;
     530  if (fsz == 0)
     531    return pos;
    530532  long fsizeminusone = (fsz - 1) * sizeof(UChar);
    531533  const UChar *fdata = f.data();
Note: See TracChangeset for help on using the changeset viewer.