From ccaaae9d0ca39ac83f54199102ce1469d5ac3a55 Mon Sep 17 00:00:00 2001 From: Karl Skomski Date: Thu, 24 Sep 2015 10:53:42 +0200 Subject: [PATCH] src: fix u-a-free if uv returns err in ASYNC_CALL PR-URL: https://github.com/nodejs/node/pull/3049 Reviewed-By: Ben Noordhuis --- src/node_file.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 223088601176fc..b84e0e44c442b0 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -273,8 +273,10 @@ struct fs_req_wrap { uv_req->result = err; \ uv_req->path = nullptr; \ After(uv_req); \ - } \ - args.GetReturnValue().Set(req_wrap->persistent()); + req_wrap = nullptr; \ + } else { \ + args.GetReturnValue().Set(req_wrap->persistent()); \ + } #define ASYNC_CALL(func, req, ...) \ ASYNC_DEST_CALL(func, req, nullptr, __VA_ARGS__) \ @@ -1028,6 +1030,7 @@ static void WriteString(const FunctionCallbackInfo& args) { uv_req->result = err; uv_req->path = nullptr; After(uv_req); + return; } return args.GetReturnValue().Set(req_wrap->persistent());