Fix NullPointerException for "abc".match("a\");

This commit is contained in:
norris%netscape.com 1999-06-02 16:12:19 +00:00
Родитель 6147ef7ade
Коммит b060e6bd7e
2 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -229,6 +229,8 @@ final class LineBuffer {
result = new String(buffer, stringStart, result = new String(buffer, stringStart,
offset - stringStart - loseCR); offset - stringStart - loseCR);
} else { } else {
if (stringSoFar == null)
stringSoFar = new StringBuffer();
// Exclude cr as well as nl of newline. If offset is 0, then // Exclude cr as well as nl of newline. If offset is 0, then
// hopefully fill() did the right thing. // hopefully fill() did the right thing.
result = (stringSoFar.append(buffer, 0, offset - loseCR)).toString(); result = (stringSoFar.append(buffer, 0, offset - loseCR)).toString();

Просмотреть файл

@ -229,6 +229,8 @@ final class LineBuffer {
result = new String(buffer, stringStart, result = new String(buffer, stringStart,
offset - stringStart - loseCR); offset - stringStart - loseCR);
} else { } else {
if (stringSoFar == null)
stringSoFar = new StringBuffer();
// Exclude cr as well as nl of newline. If offset is 0, then // Exclude cr as well as nl of newline. If offset is 0, then
// hopefully fill() did the right thing. // hopefully fill() did the right thing.
result = (stringSoFar.append(buffer, 0, offset - loseCR)).toString(); result = (stringSoFar.append(buffer, 0, offset - loseCR)).toString();