Skip to content

Commit

Permalink
fix potential segfault on reconnect
Browse files Browse the repository at this point in the history
Looking at the following bug report it would appear that calling
uv_poll_stop more than once causes a segfault. Unfortunately
I cannot reproduce this issue on node14 however I'm going to
check if uv_poll_stop has already been called before attempting
to stop it again.

jeremycx/node-LDAP#90

Signed-off-by: Joshua Houghton <[email protected]>
  • Loading branch information
joshuahoughton committed May 22, 2021
1 parent 06e5a0e commit 457c44c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cnx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,10 +1203,11 @@ on_connect (LDAP * ld, Sockbuf * sb,
uv_poll_init (loop, ldap_cnx->handle, fd);
ldap_cnx->handle->data = ldap_cnx;
}
else
else if (uv_loop_alive (ldap_cnx->handle->loop))
{
uv_poll_stop (ldap_cnx->handle);
}

uv_poll_start (ldap_cnx->handle, UV_READABLE, (uv_poll_cb) cnx_event);

status = napi_get_reference_value (ldap_cnx->env,
Expand Down Expand Up @@ -1258,7 +1259,7 @@ on_disconnect (LDAP * ld, Sockbuf * sb, struct ldap_conncb *ctx)
js_cb, 0, NULL, NULL);
rethrow_on_exception (env, status);

status = napi_close_handle_scope (ldap_cnx->env, scope);
status = napi_close_handle_scope (env, scope);
assert (status == napi_ok);
}

Expand Down

0 comments on commit 457c44c

Please sign in to comment.