]> git.meshlink.io Git - meshlink/commitdiff
Move assert()s that dereference a pointer to after the pointer NULL check.
authorGuus Sliepen <guus@meshlink.io>
Sun, 23 Feb 2020 00:41:56 +0000 (01:41 +0100)
committerGuus Sliepen <guus@meshlink.io>
Sun, 23 Feb 2020 00:41:56 +0000 (01:41 +0100)
src/meshlink.c

index 0354c86dc096d5036d6a2298c28dfd5cfbb4fd9e..fbacfd4a4131a813d8f2119a11472303a00f4886 100644 (file)
@@ -1558,9 +1558,6 @@ static void *meshlink_main_loop(void *arg) {
 }
 
 bool meshlink_start(meshlink_handle_t *mesh) {
-       assert(mesh->self);
-       assert(mesh->private_key);
-
        if(!mesh) {
                meshlink_errno = MESHLINK_EINVAL;
                return false;
@@ -1570,6 +1567,8 @@ bool meshlink_start(meshlink_handle_t *mesh) {
 
        pthread_mutex_lock(&mesh->mutex);
 
+       assert(mesh->self);
+       assert(mesh->private_key);
        assert(mesh->self->ecdsa);
        assert(!memcmp((uint8_t *)mesh->self->ecdsa + 64, (uint8_t *)mesh->private_key + 64, 32));