Exit early when mesh->confbase = NULL. That should only happen after
meshlink_close() has already been called. Also, memset() before free(),
not after.
}
void meshlink_close(meshlink_handle_t *mesh) {
- if(!mesh)
+ if(!mesh || !mesh->confbase)
return;
// Close and free all resources used.
free(mesh->name);
free(mesh->confbase);
- free(mesh);
-
memset(mesh, 0, sizeof *mesh);
+
+ free(mesh);
}
void meshlink_set_receive_cb(meshlink_handle_t *mesh, meshlink_receive_cb_t cb) {