From 24e542b4c517bfaeb06dd88b70bf1a9e2fae2af9 Mon Sep 17 00:00:00 2001 From: Tobias Boege Date: Sat, 12 Sep 2015 19:52:38 +0000 Subject: [PATCH] [GB.INOTIFY] * BUG: (Bug 730) Don't pass NULL key and zero length to GB.HashTable.Remove() * OPT: Use GB.StringLength() where possible git-svn-id: svn://localhost/gambas/trunk@7303 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- main/lib/inotify/c_watch.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main/lib/inotify/c_watch.c b/main/lib/inotify/c_watch.c index 8fb902b21..81b46fefd 100644 --- a/main/lib/inotify/c_watch.c +++ b/main/lib/inotify/c_watch.c @@ -73,7 +73,8 @@ static CWATCH *find_watch_path(CINOTIFY *ino, const char *path) { CWATCH *watch = NULL; - GB.HashTable.Get(ino->watches, path, 0, (void **) &watch); + GB.HashTable.Get(ino->watches, path, GB.StringLength((char *) path), + (void **) &watch); return watch; } @@ -128,7 +129,10 @@ static void destroy_watch(CWATCH *watch) inotify_rm_watch(_ino.fd, watch->wd); GB.HashTable.Remove(_ino.watches, (char *) &watch->wd, sizeof(watch->wd)); - GB.HashTable.Remove(_ino.watches, watch->path, 0); + if (watch->path) { + GB.HashTable.Remove(_ino.watches, watch->path, + GB.StringLength(watch->path)); + } GB.FreeString(&watch->path); GB.StoreVariant(NULL, &watch->tag);