dirmonitor: added missing mutex initialization (#1150)

This commit is contained in:
Jefferson González 2022-10-12 10:31:26 -04:00 committed by GitHub
parent 0fc793d1ae
commit 48c800cde7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -63,6 +63,7 @@ static int f_dirmonitor_new(lua_State* L) {
struct dirmonitor* monitor = lua_newuserdata(L, sizeof(struct dirmonitor));
luaL_setmetatable(L, API_TYPE_DIRMONITOR);
memset(monitor, 0, sizeof(struct dirmonitor));
monitor->mutex = SDL_CreateMutex();
monitor->internal = init_dirmonitor();
return 1;
}

View File

@ -22,6 +22,7 @@ struct dirmonitor_internal* init_dirmonitor() {
monitor->stream = NULL;
monitor->changes = NULL;
monitor->count = 0;
monitor->lock = NULL;
return monitor;
}
@ -136,6 +137,8 @@ int translate_changes_dirmonitor(
int add_dirmonitor(struct dirmonitor_internal* monitor, const char* path) {
stop_monitor_stream(monitor);
monitor->lock = SDL_CreateMutex();
FSEventStreamContext context = {
.info = monitor,
.retain = NULL,