summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/state.c14
2 files changed, 9 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index b419532..c22de55 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,10 @@
lilv (0.24.21) unstable; urgency=medium
* Fix dependencies in pkg-config file
+ * Fix potential crash when writing state files fails
* Override pkg-config dependency within meson
- -- David Robillard <d@drobilla.net> Fri, 07 Oct 2022 17:36:55 +0000
+ -- David Robillard <d@drobilla.net> Tue, 15 Nov 2022 20:21:29 +0000
lilv (0.24.20) stable; urgency=medium
diff --git a/src/state.c b/src/state.c
index 58aebf6..a662b8d 100644
--- a/src/state.c
+++ b/src/state.c
@@ -997,15 +997,15 @@ add_state_to_manifest(LilvWorld* lworld,
LILV_ERRORF(
"Failed to open %s for writing (%s)\n", manifest_path, strerror(errno));
r = 1;
+ } else {
+ SerdWriter* writer = ttl_file_writer(wfd, &manifest, &env);
+ zix_file_lock(wfd, ZIX_FILE_LOCK_BLOCK);
+ sord_write(model, writer, NULL);
+ zix_file_unlock(wfd, ZIX_FILE_LOCK_BLOCK);
+ serd_writer_free(writer);
+ fclose(wfd);
}
- SerdWriter* writer = ttl_file_writer(wfd, &manifest, &env);
- zix_file_lock(wfd, ZIX_FILE_LOCK_BLOCK);
- sord_write(model, writer, NULL);
- zix_file_unlock(wfd, ZIX_FILE_LOCK_BLOCK);
- serd_writer_free(writer);
- fclose(wfd);
-
sord_free(model);
serd_node_free(&file);
serd_node_free(&manifest);