Fix big string bug
authorRyan Dahl <ry@tinyclouds.org>
Wed, 8 Sep 2010 06:04:27 +0000 (23:04 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Thu, 9 Sep 2010 18:03:50 +0000 (11:03 -0700)
src/node_buffer.cc
test/simple/test-buffer.js

index a4e3671..5cb204c 100644 (file)
@@ -511,8 +511,8 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {
             "Offset is out of bounds")));
   }
 
-  size_t max_length = args[2].IsEmpty() ? buffer->length_ - offset
-                                        : args[2]->Uint32Value();
+  size_t max_length = args[2]->IsUndefined() ? buffer->length_ - offset
+                                             : args[2]->Uint32Value();
   max_length = MIN(buffer->length_ - offset, max_length);
 
   char* p = buffer->data() + offset;
@@ -553,8 +553,8 @@ Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
             "Offset is out of bounds")));
   }
 
-  size_t max_length = args[2].IsEmpty() ? buffer->length_ - offset
-                                        : args[2]->Uint32Value();
+  size_t max_length = args[2]->IsUndefined() ? buffer->length_ - offset
+                                             : args[2]->Uint32Value();
   max_length = MIN(s->Length(), MIN(buffer->length_ - offset, max_length));
 
   char *p = buffer->data() + offset;
index 99fb8bc..933b48e 100644 (file)
@@ -303,10 +303,10 @@ for (i = 0; i < l; i++) {
   s += "h";
 }
 
-b = Buffer(s);
+b = new Buffer(s);
 
-for (i = 0; l; i++) {
-  assert.equal("h".charCodeAt(i), b[i], "index " + i + " is not 'h' it was " + b[i]);
+for (i = 0; i < l; i++) {
+  assert.equal("h".charCodeAt(0), b[i]);
 }
 
 sb = b.toString();