Fix potential null pointer access after the allocation error

This commit is contained in:
Vladislav Vaintroub 2021-09-01 18:21:34 +02:00
parent 234ae43d5a
commit d6b7738dcc

View file

@ -196,6 +196,8 @@ datadir_iter_new(const char *path, bool skip_first_level = true)
datadir_iter_t *it;
it = static_cast<datadir_iter_t *>(malloc(sizeof(datadir_iter_t)));
if (!it)
goto error;
memset(it, 0, sizeof(datadir_iter_t));
pthread_mutex_init(&it->mutex, NULL);