sd-bus: initialize mutex after we allocated the wqueue

That way the mutex doesn't have to be destroyed when we exit early due
to OOM.
This commit is contained in:
Lennart Poettering 2019-01-17 21:06:30 +01:00
parent 8f37636d91
commit 2fe9a10d76
1 changed files with 2 additions and 2 deletions

View File

@ -248,12 +248,12 @@ _public_ int sd_bus_new(sd_bus **ret) {
.close_on_exit = true,
};
assert_se(pthread_mutex_init(&b->memfd_cache_mutex, NULL) == 0);
/* We guarantee that wqueue always has space for at least one entry */
if (!GREEDY_REALLOC(b->wqueue, b->wqueue_allocated, 1))
return -ENOMEM;
assert_se(pthread_mutex_init(&b->memfd_cache_mutex, NULL) == 0);
*ret = TAKE_PTR(b);
return 0;
}