summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-11-15 15:21:54 -0500
committerDavid Robillard <d@drobilla.net>2022-11-16 10:22:55 -0500
commitb865c0bc123df3561ce7cde70af8d08e8f1055a3 (patch)
treeb0b87b80c56d72a7356990e0e8e6e7f760a3fa45
parent6fe4c50fee3adf77f9ef18e89445a043db281eb8 (diff)
downloadlilv-b865c0bc123df3561ce7cde70af8d08e8f1055a3.tar.gz
lilv-b865c0bc123df3561ce7cde70af8d08e8f1055a3.tar.bz2
lilv-b865c0bc123df3561ce7cde70af8d08e8f1055a3.zip
Fix potential crash when writing state files fails
-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);