src: fix u-a-free if uv returns err in ASYNC_CALL
authorKarl Skomski <karl@skomski.com>
Thu, 24 Sep 2015 08:53:42 +0000 (10:53 +0200)
committerJames M Snell <jasnell@gmail.com>
Fri, 9 Oct 2015 03:29:04 +0000 (20:29 -0700)
PR-URL: https://github.com/nodejs/node/pull/3049
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
src/node_file.cc

index 2230886..b84e0e4 100644 (file)
@@ -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<Value>& args) {
     uv_req->result = err;
     uv_req->path = nullptr;
     After(uv_req);
+    return;
   }
 
   return args.GetReturnValue().Set(req_wrap->persistent());