From b597d157791d83ad49130bfec3718231da2e0aef Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 12 Mar 2014 21:31:33 +0400 Subject: [PATCH] stream: do not leak `alloc_cb` buffers on error Always pass previously allocated (if any) buffer, when calling `read_cb()` on error. --- src/unix/stream.c | 2 +- src/win/pipe.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index 370894bf..76da0618 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -1127,7 +1127,7 @@ static void uv__read(uv_stream_t* stream) { if (is_ipc) { err = uv__stream_recv_cmsg(stream, &msg); if (err != 0) { - stream->read_cb(stream, err, NULL); + stream->read_cb(stream, err, &buf); return; } } diff --git a/src/win/pipe.c b/src/win/pipe.c index b832a28c..13feba5d 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -1347,7 +1347,7 @@ static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle, handle->flags &= ~UV_HANDLE_READABLE; uv_read_stop((uv_stream_t*) handle); - handle->read_cb((uv_stream_t*) handle, UV_EOF, &uv_null_buf_); + handle->read_cb((uv_stream_t*) handle, UV_EOF, &buf); } @@ -1505,7 +1505,7 @@ void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, break; } } else { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); + uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf); break; } }