Fix memory leak on fs.write()
authorRyan Dahl <ry@tinyclouds.org>
Sat, 21 Nov 2009 23:47:26 +0000 (00:47 +0100)
committerRyan Dahl <ry@tinyclouds.org>
Sat, 21 Nov 2009 23:47:36 +0000 (00:47 +0100)
Reported by onne@onnlucky.com.

src/node_file.cc

index f4cda23..399ec88 100644 (file)
@@ -118,6 +118,10 @@ int EIOPromise::After(eio_req *req) {
     Local<Value> exception = Exception::Error(
         String::NewSymbol(strerror(req->errorno)));
     promise->EmitError(1, &exception);
+    if (req->type == EIO_WRITE) {
+      assert(req->ptr2);
+      delete [] req->ptr2;
+    }
     return 0;
   }