1.1 --- a/libfsclient/lib/src/file.cc Tue Aug 17 23:44:36 2021 +0200
1.2 +++ b/libfsclient/lib/src/file.cc Sat Aug 21 19:26:33 2021 +0200
1.3 @@ -98,9 +98,11 @@
1.4 ipc_cap_free_um(file->ref);
1.5
1.6 /* Only unsubscribe after actually closing the file and sending any
1.7 - notifications. */
1.8 + notifications. This depends on a valid reference, so it is also tested
1.9 + here. */
1.10
1.11 - get_task_notifier()->unsubscribe(file);
1.12 + if (l4_is_valid_cap(file->ref))
1.13 + get_task_notifier()->unsubscribe(file);
1.14
1.15 if (file->memory != NULL)
1.16 ipc_detach_dataspace(file->memory);
1.17 @@ -183,6 +185,9 @@
1.18
1.19 long file_flush(file_t *file)
1.20 {
1.21 + if (l4_is_invalid_cap(file->ref))
1.22 + return -L4_EINVAL;
1.23 +
1.24 client_Flush _file(file->ref);
1.25 long err = _file.flush(file->data_current, &file->size);
1.26