Fix NULL dereference in w32notify.c

* src/w32notify.c (start_watching): Return NULL instead of freed
pointer.
(add_watch): Fix NULL dereference.
This commit is contained in:
Stefan Kangas 2024-01-13 10:20:41 +01:00
parent 1bfc7fd33d
commit 893829021b

View file

@ -350,6 +350,7 @@ start_watching (const char *file, HANDLE hdir, BOOL subdirs, DWORD flags)
xfree (dirwatch->io_info); xfree (dirwatch->io_info);
xfree (dirwatch->watchee); xfree (dirwatch->watchee);
xfree (dirwatch); xfree (dirwatch);
return NULL;
} }
return dirwatch; return dirwatch;
} }
@ -412,10 +413,7 @@ add_watch (const char *parent_dir, const char *file, BOOL subdirs, DWORD flags)
return NULL; return NULL;
if ((dirwatch = start_watching (file, hdir, subdirs, flags)) == NULL) if ((dirwatch = start_watching (file, hdir, subdirs, flags)) == NULL)
{ CloseHandle (hdir);
CloseHandle (hdir);
dirwatch->dir = NULL;
}
return dirwatch; return dirwatch;
} }