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

Side by Side Diff: src/uri.h

Issue 199583007: Reland "Throw exception on invalid string length instead of OOM." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: change 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 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
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_
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