diff options
-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 |