Fix memory leak in fs.writeSync()
authorRyan Dahl <ry@tinyclouds.org>
Mon, 3 May 2010 00:02:13 +0000 (17:02 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 3 May 2010 00:02:13 +0000 (17:02 -0700)
src/node_file.cc

index e417819..bc48a12 100644 (file)
@@ -564,11 +564,8 @@ static Handle<Value> Write(const Arguments& args) {
 
   } else {
     if (legacy) {
-      if (pos < 0) {
-        written = write(fd, buf, len);
-      } else {
-        written = pwrite(fd, buf, len, pos);
-      }
+      written = pos < 0 ? write(fd, buf, len) : pwrite(fd, buf, len, pos);
+      delete [] reinterpret_cast<char*>(buf);
       if (written < 0) return ThrowException(ErrnoException(errno));
       return scope.Close(Integer::New(written));
     } else {