]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Add missing checks for NULL mesh pointers in the public API.
[meshlink] / src / meshlink.c
index c34b24c9643f4bde69e2904877502e78c01f2b86..31fc205aef72e745b6b3215de26392cd391cb7c8 100644 (file)
@@ -391,7 +391,10 @@ static int getifaddrs_in_netns(struct ifaddrs **ifa, int netns) {
 #endif
 
 char *meshlink_get_local_address_for_family(meshlink_handle_t *mesh, int family) {
-       (void)mesh;
+       if(!mesh) {
+               meshlink_errno = MESHLINK_EINVAL;
+               return NULL;
+       }
 
        // Determine address of the local interface used for outgoing connections.
        char localaddr[NI_MAXHOST];
@@ -3863,7 +3866,7 @@ static void channel_retransmit(struct utcp_connection *utcp_connection) {
        node_t *n = utcp_connection->utcp->priv;
        meshlink_handle_t *mesh = n->mesh;
 
-       if(n->mtuprobes == 31) {
+       if(n->mtuprobes == 31 && n->mtutimeout.cb) {
                timeout_set(&mesh->loop, &n->mtutimeout, &(struct timespec) {
                        0, 0
                });
@@ -4052,9 +4055,7 @@ void meshlink_set_channel_accept_cb(meshlink_handle_t *mesh, meshlink_channel_ac
 }
 
 void meshlink_set_channel_sndbuf(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t size) {
-       (void)mesh;
-
-       if(!channel) {
+       if(!mesh || !channel) {
                meshlink_errno = MESHLINK_EINVAL;
                return;
        }
@@ -4068,9 +4069,7 @@ void meshlink_set_channel_sndbuf(meshlink_handle_t *mesh, meshlink_channel_t *ch
 }
 
 void meshlink_set_channel_rcvbuf(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t size) {
-       (void)mesh;
-
-       if(!channel) {
+       if(!mesh || !channel) {
                meshlink_errno = MESHLINK_EINVAL;
                return;
        }