Skip to content

Instantly share code, notes, and snippets.

@saghul
Created February 28, 2014 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saghul/9267731 to your computer and use it in GitHub Desktop.
Save saghul/9267731 to your computer and use it in GitHub Desktop.
diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc
index 4876422..4d6cdf3 100644
--- a/src/spawn_sync.cc
+++ b/src/spawn_sync.cc
@@ -450,9 +450,10 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
assert(lifecycle_ == kUninitialized);
lifecycle_ = kInitialized;
- uv_loop_ = uv_loop_new();
+ uv_loop_ = static_cast<uv_loop_t*>(malloc(sizeof *uv_loop_));
if (uv_loop_ == NULL)
return SetError(UV_ENOMEM);
+ uv_loop_init(uv_loop_);
r = ParseOptions(options);
if (r < 0)
@@ -515,7 +516,9 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
if (r < 0)
abort();
- uv_loop_delete(uv_loop_);
+ assert(uv_loop_close(uv_loop_) == 0);
+ free(uv_loop_);
+ uv_loop_ = NULL;
} else {
// If the loop doesn't exist, neither should any pipes or timers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment