summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-11 01:03:11 +0100
committerDavid Robillard <d@drobilla.net>2020-11-11 01:03:11 +0100
commit036c954b0a43b033a3054e4d77faf54bf4e01eef (patch)
tree8c09eddcfdf4776a8a6496330d62df0119b12b45
parent005418ac17e6a6a370c032db1c6e107612a94346 (diff)
downloadlilv-036c954b0a43b033a3054e4d77faf54bf4e01eef.tar.gz
lilv-036c954b0a43b033a3054e4d77faf54bf4e01eef.tar.bz2
lilv-036c954b0a43b033a3054e4d77faf54bf4e01eef.zip
Fix potential memory error when joining filesystem paths
-rw-r--r--NEWS6
-rw-r--r--src/filesystem.c9
-rw-r--r--wscript2
3 files changed, 12 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index a9e4f2a..d93f736 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+lilv (0.24.11) unstable;
+
+ * Fix potential memory error when joining filesystem paths
+
+ -- David Robillard <d@drobilla.net> Wed, 11 Nov 2020 00:02:31 +0000
+
lilv (0.24.10) stable;
* Fix memory leaks in lv2bench
diff --git a/src/filesystem.c b/src/filesystem.c
index 7cda4d9..c8a58c1 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -199,10 +199,11 @@ lilv_path_join(const char* a, const char* b)
return (b && b[0]) ? lilv_strdup(b) : NULL;
}
- const size_t a_len = strlen(a);
- const size_t b_len = b ? strlen(b) : 0;
- const size_t pre_len = a_len - (lilv_is_dir_sep(a[a_len - 1]) ? 1 : 0);
- char* path = (char*)calloc(1, a_len + b_len + 2);
+ const size_t a_len = strlen(a);
+ const size_t b_len = b ? strlen(b) : 0;
+ const bool a_end_is_sep = a_len > 0 && lilv_is_dir_sep(a[a_len - 1]);
+ const size_t pre_len = a_len - (a_end_is_sep ? 1 : 0);
+ char* path = (char*)calloc(1, a_len + b_len + 2);
memcpy(path, a, pre_len);
path[pre_len] = '/';
if (b) {
diff --git a/wscript b/wscript
index f6780d0..2588fd4 100644
--- a/wscript
+++ b/wscript
@@ -12,7 +12,7 @@ from waflib.extras import autowaf
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
-LILV_VERSION = '0.24.10'
+LILV_VERSION = '0.24.11'
LILV_MAJOR_VERSION = '0'
# Mandatory waf variables