From 5457eae28c24739d2d0d779ab0f7deb4999a3636 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 2 May 2010 17:02:13 -0700 Subject: [PATCH] Fix memory leak in fs.writeSync() --- src/node_file.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index e417819138..bc48a1258f 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -564,11 +564,8 @@ static Handle 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(buf); if (written < 0) return ThrowException(ErrnoException(errno)); return scope.Close(Integer::New(written)); } else {