Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index f3fb849de4dd81aad03cda7f96053aa8b822b2c5..0d9525d25b62a5b04278befb94f2faa7dbd98ea8 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -2132,7 +2132,8 @@ static Object* ConvertCase(Arguments args, |
| // We can assume that the string is not empty |
| uc32 current = buffer->GetNext(); |
| while (i < length) { |
| - uc32 next = buffer->has_more() ? buffer->GetNext() : 0; |
| + bool has_next = buffer->has_more(); |
| + uc32 next = has_next ? buffer->GetNext() : 0; |
| int char_length = mapping->get(current, next, chars); |
| if (char_length == 0) { |
| // The case conversion of this character is the character itself. |
| @@ -2156,12 +2157,17 @@ static Object* ConvertCase(Arguments args, |
| // "realloc" it and probably, in the vast majority of cases, |
| // extend the existing string to be able to hold the full |
| // result. |
| - int current_length = i + char_length + mapping->get(next, 0, chars); |
| + int next_length = 0; |
| + if (has_next) { |
| + next_length = mapping->get(next, 0, chars); |
|
Erik Corry
2008/10/14 09:01:53
Missing comment here to explain why 0 is OK.
|
| + if (next_length == 0) next_length = 1; |
| + } |
| + int current_length = i + char_length + next_length; |
| while (buffer->has_more()) { |
| current = buffer->GetNext(); |
| int char_length = mapping->get(current, 0, chars); |
| if (char_length == 0) char_length = 1; |
| - current += char_length; |
| + current_length += char_length; |
| } |
| length = current_length; |
| goto try_convert; |