diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-09-02 11:56:37 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-09-02 13:54:32 +0100 |
commit | b80bc3a17fd78f8b665509cb193e876b2d16497c (patch) | |
tree | f69aaa7538c26fc42cfca19adb43d7a94701f8c1 /socket/http.c | |
parent | bb33879742c3572ab097ce82e24ece5122f547fc (diff) | |
download | libnice-b80bc3a17fd78f8b665509cb193e876b2d16497c.tar.gz |
socket: Return early from socket functions if the socket is closed
Explicitly check whether the socket is closed (universally represented
as sock->priv == NULL) before doing anything else in the socket methods.
This should safely return from unusual situations where the socket has
been closed and part-destroyed but still ends up having send() or recv()
called on it.
Diffstat (limited to 'socket/http.c')
-rw-r--r-- | socket/http.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/socket/http.c b/socket/http.c index 41ce1c3..404d378 100644 --- a/socket/http.c +++ b/socket/http.c @@ -195,6 +195,7 @@ socket_close (NiceSocket *sock) nice_socket_free_send_queue (&priv->send_queue); g_slice_free(HttpPriv, sock->priv); + sock->priv = NULL; } static void @@ -280,6 +281,10 @@ socket_recv_messages (NiceSocket *sock, HttpPriv *priv = sock->priv; gint ret = -1; + /* Socket has been closed: */ + if (sock->priv == NULL) + return 0; + if (priv->state == HTTP_STATE_CONNECTED) { guint i; @@ -571,6 +576,10 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to, { HttpPriv *priv = sock->priv; + /* Socket has been closed: */ + if (sock->priv == NULL) + return -1; + if (priv->state == HTTP_STATE_CONNECTED) { /* Fast path. */ if (!priv->base_socket) |