]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Fix errors found by Clang's static analyzer.
[meshlink] / src / meshlink.c
index 5d75e0688bcda7858048b57ed9d3644750f0cc6d..90cdf0db6d3b644cb45cb144c04a9652ffd315cb 100644 (file)
@@ -1208,8 +1208,8 @@ bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const
        memset(hdr, 0, sizeof(*hdr));
        // leave the last byte as 0 to make sure strings are always
        // null-terminated if they are longer than the buffer
-       strncpy(hdr->destination, destination->name, (sizeof(hdr)->destination) - 1);
-       strncpy(hdr->source, mesh->self->name, (sizeof(hdr)->source) - 1);
+       strncpy((char *)hdr->destination, destination->name, (sizeof(hdr)->destination) - 1);
+       strncpy((char *)hdr->source, mesh->self->name, (sizeof(hdr)->source) - 1);
 
        memcpy(packet->data + sizeof(*hdr), data, len);
 
@@ -1946,6 +1946,7 @@ char *meshlink_export(meshlink_handle_t *mesh) {
        if(fread(buf + len - fsize - 1, fsize, 1, f) != 1) {
                logger(mesh, MESHLINK_DEBUG, "Error reading from %s: %s\n", filename, strerror(errno));
                fclose(f);
+               free(buf);
                meshlink_errno = MESHLINK_ESTORAGE;
                pthread_mutex_unlock(&(mesh->mesh_mutex));
                return NULL;