aboutsummaryrefslogtreecommitdiff
path: root/fiv-io-model.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-08-03 04:34:05 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-08-03 04:42:50 +0200
commit2d10aa8b612d6975ec57339051e0b2116a2e45e5 (patch)
tree5b804bb830243dbb2003a09f4d8e42c8c69d472b /fiv-io-model.c
parent1ec41f7749412ee96e4dc1eb03ed993c0d89b555 (diff)
downloadfiv-2d10aa8b612d6975ec57339051e0b2116a2e45e5.tar.gz
fiv-2d10aa8b612d6975ec57339051e0b2116a2e45e5.tar.xz
fiv-2d10aa8b612d6975ec57339051e0b2116a2e45e5.zip
Prevent a class of crashes in monitoring
Diffstat (limited to 'fiv-io-model.c')
-rw-r--r--fiv-io-model.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fiv-io-model.c b/fiv-io-model.c
index 2f8b192..2ee1002 100644
--- a/fiv-io-model.c
+++ b/fiv-io-model.c
@@ -346,6 +346,8 @@ static void
monitor_apply(enum monitor_event event, GPtrArray *target, int index,
FivIoModelEntry *new_entry)
{
+ g_return_if_fail(event != MONITOR_CHANGING || index >= 0);
+
if (event == MONITOR_RENAMING && index < 0)
// The file used to be filtered out but isn't anymore.
event = MONITOR_ADDING;
@@ -706,7 +708,7 @@ fiv_io_model_open(FivIoModel *self, GFile *directory, GError **error)
GError *e = NULL;
if ((self->monitor = g_file_monitor_directory(
- directory, G_FILE_MONITOR_WATCH_MOVES, NULL, &e))) {
+ directory, G_FILE_MONITOR_WATCH_MOVES, NULL, &e))) {
g_signal_connect(self->monitor, "changed",
G_CALLBACK(on_monitor_changed), self);
} else {