Revision: 8419
Author:   [email protected]
Date:     Fri Jun 24 06:44:27 2011
Log:      Check for empty substring.
Review URL: http://codereview.chromium.org/7237023
http://code.google.com/p/v8/source/detail?r=8419

Modified:
 /branches/bleeding_edge/src/heap.cc

=======================================
--- /branches/bleeding_edge/src/heap.cc Fri Jun 24 04:38:47 2011
+++ /branches/bleeding_edge/src/heap.cc Fri Jun 24 06:44:27 2011
@@ -2634,12 +2634,13 @@


 MaybeObject* Heap::AllocateSubString(String* buffer,
-                                int start,
-                                int end,
-                                PretenureFlag pretenure) {
+                                     int start,
+                                     int end,
+                                     PretenureFlag pretenure) {
   int length = end - start;
-
-  if (length == 1) {
+  if (length == 0) {
+    return empty_string();
+  } else if (length == 1) {
     return LookupSingleCharacterStringFromCode(buffer->Get(start));
   } else if (length == 2) {
// Optimization for 2-byte strings often used as keys in a decompression

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to