Created
August 2, 2011 22:03
-
-
Save piscisaureus/1121347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 15a5ff1b180c48b7f10ba0dea3b1d00ec531a685 Mon Sep 17 00:00:00 2001 | |
From: unknown <Bert Belder@.(none)> | |
Date: Tue, 2 Aug 2011 23:03:07 +0100 | |
Subject: [PATCH 1/1] Windows: avoid errorneous freeing of pipe handle | |
--- | |
deps/uv/src/win/pipe.c | 7 ++++++- | |
1 files changed, 6 insertions(+), 1 deletions(-) | |
diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c | |
index 1eb4973..e620fd7 100644 | |
--- a/deps/uv/src/win/pipe.c | |
+++ b/deps/uv/src/win/pipe.c | |
@@ -147,6 +147,7 @@ static int uv_set_pipe_handle(uv_pipe_t* handle, HANDLE pipeHandle) { | |
void uv_pipe_endgame(uv_pipe_t* handle) { | |
uv_err_t err; | |
int status; | |
+ int uv_alloced; | |
if (handle->flags & UV_HANDLE_SHUTTING && | |
!(handle->flags & UV_HANDLE_SHUT) && | |
@@ -167,11 +168,15 @@ void uv_pipe_endgame(uv_pipe_t* handle) { | |
assert(!(handle->flags & UV_HANDLE_CLOSED)); | |
handle->flags |= UV_HANDLE_CLOSED; | |
+ /* Remember the state of this flag because the close callback is */ | |
+ /* allowed to clobber or free the handle's memory */ | |
+ uv_alloced = handle->flags & UV_HANDLE_UV_ALLOCED; | |
+ | |
if (handle->close_cb) { | |
handle->close_cb((uv_handle_t*)handle); | |
} | |
- if (handle->flags & UV_HANDLE_UV_ALLOCED) { | |
+ if (uv_alloced) { | |
free(handle); | |
} | |
-- | |
1.7.6.msysgit.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment