diff options
author | Eugene K <eugene.kobyakov@netfoundry.io> | 2023-01-02 10:59:58 -0500 |
---|---|---|
committer | Eugene K <eugene.kobyakov@netfoundry.io> | 2023-01-02 10:59:58 -0500 |
commit | 8cb4515e530ee46dbfb314320b3e4d93c27e7c97 (patch) | |
tree | 9b789b57d5d9594f5d201de76e646bd64cc27577 /src | |
parent | 784379dcc3294b9682b625805187ac0fdd8a08f0 (diff) | |
download | uv_link_t-8cb4515e530ee46dbfb314320b3e4d93c27e7c97.tar.gz |
fix crashes when close() is called without stream set
Diffstat (limited to 'src')
-rw-r--r-- | src/uv_link_source_t.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/uv_link_source_t.c b/src/uv_link_source_t.c index 96fc937..7907d65 100644 --- a/src/uv_link_source_t.c +++ b/src/uv_link_source_t.c @@ -143,7 +143,11 @@ static void uv_link_source_close_cb(uv_handle_t* handle) { source = handle->data; source->stream = NULL; - source->close_cb(source->close_source); + if (source->close_cb) { + source->close_cb(source->close_source); + } + source->close_cb = NULL; + source->close_source = NULL; } @@ -153,10 +157,15 @@ static void uv_link_source_close(uv_link_t* link, uv_link_t* source, s = (uv_link_source_t*) link; - s->close_cb = cb; - s->close_source = source; - - uv_close((uv_handle_t*) s->stream, uv_link_source_close_cb); + if (s->stream) { + if (!uv_is_closing((const uv_handle_t *) s->stream)) { + s->close_cb = cb; + s->close_source = source; + uv_close((uv_handle_t *) s->stream, uv_link_source_close_cb); + } + } else { + cb(source); + } } |