From: Ryan Dahl Date: Mon, 3 May 2010 00:02:13 +0000 (-0700) Subject: Fix memory leak in fs.writeSync() X-Git-Tag: v0.1.94~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5457eae28c24739d2d0d779ab0f7deb4999a3636;p=platform%2Fupstream%2Fnodejs.git Fix memory leak in fs.writeSync() --- diff --git a/src/node_file.cc b/src/node_file.cc index e417819..bc48a12 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 {