Commit b58e852d authored by Olivier Crête's avatar Olivier Crête

socket: Assert trying to use free'd socket

Cleanly returnign makes no sense and may hide
worse problems.
parent baab2c3c
......@@ -283,9 +283,8 @@ socket_recv_messages (NiceSocket *sock,
HttpPriv *priv = sock->priv;
gint ret = -1;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (priv->state == HTTP_STATE_CONNECTED) {
guint i;
......@@ -578,9 +577,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
HttpPriv *priv = sock->priv;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (priv->state == HTTP_STATE_CONNECTED) {
/* Fast path. */
......
......@@ -206,9 +206,8 @@ socket_recv_messages (NiceSocket *sock,
{
PseudoSSLPriv *priv = sock->priv;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (priv->handshaken) {
if (priv->base_socket) {
......@@ -258,9 +257,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
PseudoSSLPriv *priv = sock->priv;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (priv->handshaken) {
/* Fast path: pass directly through to the base socket once the handshake is
......
......@@ -169,9 +169,8 @@ socket_recv_messages (NiceSocket *sock,
guint i;
gint ret = -1;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
switch (priv->state) {
case SOCKS_STATE_CONNECTED:
......@@ -425,9 +424,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
Socks5Priv *priv = sock->priv;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (priv->state == SOCKS_STATE_CONNECTED) {
/* Fast path: pass through to the base socket once connected. */
......
......@@ -237,9 +237,8 @@ socket_recv_messages (NiceSocket *sock,
TcpPriv *priv = sock->priv;
guint i;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
/* Don't try to access the socket if it had an error */
if (priv->error)
......@@ -291,9 +290,8 @@ socket_send_message (NiceSocket *sock,
GError *gerr = NULL;
gsize message_len;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
/* Don't try to access the socket if it had an error, otherwise we risk a
* crash with SIGPIPE (Broken pipe) */
......@@ -352,9 +350,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
guint i;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
for (i = 0; i < n_messages; i++) {
const NiceOutputMessage *message = &messages[i];
......
......@@ -183,9 +183,8 @@ socket_recv_messages (NiceSocket *sock,
guint i;
gboolean error = FALSE;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
/* Read messages into recv_messages until one fails or would block, or we
* reach the end. */
......@@ -248,9 +247,8 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
GError *child_error = NULL;
gssize len;
/* Socket has been closed: */
if (priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (!nice_address_is_valid (&priv->niceaddr) ||
!nice_address_equal (&priv->niceaddr, to)) {
......@@ -292,9 +290,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
guint i;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
for (i = 0; i < n_messages; i++) {
const NiceOutputMessage *message = &messages[i];
......
......@@ -136,9 +136,8 @@ socket_recv_message (NiceSocket *sock, NiceInputMessage *recv_message)
GInputVector local_recv_buf;
NiceInputMessage local_recv_message;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
if (priv->expecting_len == 0) {
guint headerlen = 0;
......@@ -243,9 +242,8 @@ socket_recv_messages (NiceSocket *nicesock,
guint i;
gboolean error = FALSE;
/* Socket has been closed: */
if (nicesock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (nicesock->priv != NULL);
for (i = 0; i < n_recv_messages; i++) {
gssize len;
......@@ -287,9 +285,8 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
} header_buf;
guint offset = 0;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
/* Count the number of buffers. */
if (message->n_buffers == -1) {
......@@ -388,9 +385,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
guint i;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
for (i = 0; i < n_messages; i++) {
const NiceOutputMessage *message = &messages[i];
......
......@@ -341,9 +341,8 @@ socket_recv_messages (NiceSocket *sock,
gboolean error = FALSE;
guint n_valid_messages;
/* Socket has been closed: */
if (sock->priv == NULL)
return 0;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
nice_debug_verbose ("received message on TURN socket");
......@@ -700,9 +699,8 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
ChannelBinding *binding = NULL;
gint ret;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
for (i = priv->channels; i; i = i->next) {
ChannelBinding *b = i->data;
......@@ -876,9 +874,8 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
{
guint i;
/* Socket has been closed: */
if (sock->priv == NULL)
return -1;
/* Make sure socket has not been freed: */
g_assert (sock->priv != NULL);
for (i = 0; i < n_messages; i++) {
const NiceOutputMessage *message = &messages[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment