socket: Ensure variables are nullified correctly in UDP sockets
When closing a socket, ensure its private data structure is set to NULL.
When sending a message fails to construct a new socket address, ensure
the pointer to the old address (which has just been unreffed) is removed.
This makes debugging problems with sockets being freed early much
easier.
Philip Withnall authored 10 years ago
Olivier CrĂȘte committed 10 years ago
157 | 157 | if (priv->gaddr) |
158 | 158 | g_object_unref (priv->gaddr); |
159 | 159 | g_slice_free (struct UdpBsdSocketPrivate, sock->priv); |
160 | sock->priv = NULL; | |
160 | 161 | |
161 | 162 | if (sock->fileno) { |
162 | 163 | g_socket_close (sock->fileno, NULL); |
217 | 218 | g_object_unref (priv->gaddr); |
218 | 219 | nice_address_copy_to_sockaddr (to, &sa.addr); |
219 | 220 | gaddr = g_socket_address_new_from_native (&sa.addr, sizeof(sa)); |
221 | priv->gaddr = gaddr; | |
220 | 222 | if (gaddr == NULL) |
221 | 223 | return -1; |
222 | priv->gaddr = gaddr; | |
223 | 224 | priv->niceaddr = *to; |
224 | 225 | } |
225 | 226 |