Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: src/uri.h

Issue 206383002: Revert "Throw exception on invalid string length instead of OOM." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 AllowHeapAllocation allocate_error_and_return; 267 isolate->context()->mark_out_of_memory();
268 isolate->ThrowInvalidStringLength();
269 return Handle<String>::null(); 268 return Handle<String>::null();
270 } 269 }
271 } 270 }
272 } 271 }
273 272
274 // No length change implies no change. Return original string if no change. 273 // No length change implies no change. Return original string if no change.
275 if (escaped_length == length) return string; 274 if (escaped_length == length) return string;
276 275
277 Handle<SeqOneByteString> dest = 276 Handle<SeqOneByteString> dest =
278 isolate->factory()->NewRawOneByteString(escaped_length); 277 isolate->factory()->NewRawOneByteString(escaped_length);
(...skipping 22 matching lines...) Expand all
301 } 300 }
302 } 301 }
303 } 302 }
304 303
305 return dest; 304 return dest;
306 } 305 }
307 306
308 } } // namespace v8::internal 307 } } // namespace v8::internal
309 308
310 #endif // V8_URI_H_ 309 #endif // V8_URI_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698