OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 escaped_length += 6; | 257 escaped_length += 6; |
258 } else if (IsNotEscaped(c)) { | 258 } else if (IsNotEscaped(c)) { |
259 escaped_length++; | 259 escaped_length++; |
260 } else { | 260 } else { |
261 escaped_length += 3; | 261 escaped_length += 3; |
262 } | 262 } |
263 | 263 |
264 // We don't allow strings that are longer than a maximal length. | 264 // We don't allow strings that are longer than a maximal length. |
265 ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow. | 265 ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow. |
266 if (escaped_length > String::kMaxLength) { | 266 if (escaped_length > String::kMaxLength) { |
267 isolate->context()->mark_out_of_memory(); | 267 AllowHeapAllocation allocate_error_and_return; |
| 268 isolate->ThrowInvalidStringLength(); |
268 return Handle<String>::null(); | 269 return Handle<String>::null(); |
269 } | 270 } |
270 } | 271 } |
271 } | 272 } |
272 | 273 |
273 // No length change implies no change. Return original string if no change. | 274 // No length change implies no change. Return original string if no change. |
274 if (escaped_length == length) return string; | 275 if (escaped_length == length) return string; |
275 | 276 |
276 Handle<SeqOneByteString> dest = | 277 Handle<SeqOneByteString> dest = |
277 isolate->factory()->NewRawOneByteString(escaped_length); | 278 isolate->factory()->NewRawOneByteString(escaped_length); |
(...skipping 22 matching lines...) Expand all Loading... |
300 } | 301 } |
301 } | 302 } |
302 } | 303 } |
303 | 304 |
304 return dest; | 305 return dest; |
305 } | 306 } |
306 | 307 |
307 } } // namespace v8::internal | 308 } } // namespace v8::internal |
308 | 309 |
309 #endif // V8_URI_H_ | 310 #endif // V8_URI_H_ |
OLD | NEW |