diff options
author | David Robillard <d@drobilla.net> | 2020-11-11 01:03:11 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-11 01:03:11 +0100 |
commit | 036c954b0a43b033a3054e4d77faf54bf4e01eef (patch) | |
tree | 8c09eddcfdf4776a8a6496330d62df0119b12b45 | |
parent | 005418ac17e6a6a370c032db1c6e107612a94346 (diff) | |
download | lilv-036c954b0a43b033a3054e4d77faf54bf4e01eef.tar.gz lilv-036c954b0a43b033a3054e4d77faf54bf4e01eef.tar.bz2 lilv-036c954b0a43b033a3054e4d77faf54bf4e01eef.zip |
Fix potential memory error when joining filesystem paths
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | src/filesystem.c | 9 | ||||
-rw-r--r-- | wscript | 2 |
3 files changed, 12 insertions, 5 deletions
@@ -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) { @@ -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 |