summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--meson.build2
-rw-r--r--tools/lv2apply.c17
3 files changed, 15 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 1ca107b..53176bd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
lilv (0.24.25) unstable; urgency=medium
* Add lint option with project metadata and code quality tests
+ * Avoid use of VLAs in lv2apply
* Clean up and isolate platform-specific code
* Fix C++ test build on MacOS
* Fix library current_version on MacOS
@@ -9,7 +10,7 @@ lilv (0.24.25) unstable; urgency=medium
* Improve const correctness
* Replace more platform-specific code with use of zix
- -- David Robillard <d@drobilla.net> Wed, 11 Dec 2024 19:33:58 +0000
+ -- David Robillard <d@drobilla.net> Wed, 18 Dec 2024 17:57:56 +0000
lilv (0.24.24) stable; urgency=medium
diff --git a/meson.build b/meson.build
index 4c1cd99..a3a2c27 100644
--- a/meson.build
+++ b/meson.build
@@ -59,7 +59,6 @@ if cc.get_id() in ['clang', 'emscripten']
'-Wno-switch-default',
'-Wno-switch-enum',
'-Wno-unsafe-buffer-usage',
- '-Wno-vla',
]
if not meson.is_cross_build()
@@ -104,7 +103,6 @@ elif cc.get_id() == 'gcc'
'-Wno-unsuffixed-float-constants',
'-Wno-unused-const-variable',
'-Wno-unused-parameter',
- '-Wno-vla',
]
endif
diff --git a/tools/lv2apply.c b/tools/lv2apply.c
index 0792eed..3caf49a 100644
--- a/tools/lv2apply.c
+++ b/tools/lv2apply.c
@@ -212,6 +212,12 @@ print_usage(int status)
return status;
}
+static float*
+alloc_audio_buffer(size_t n_channels)
+{
+ return (float*)calloc(n_channels ? n_channels : 1, sizeof(float));
+}
+
int
main(int argc, char** argv)
{
@@ -319,8 +325,8 @@ main(int argc, char** argv)
/* Instantiate plugin and connect ports */
const uint32_t n_ports = lilv_plugin_get_num_ports(plugin);
- float in_buf[self.n_audio_in > 0 ? self.n_audio_in : 1];
- float out_buf[self.n_audio_out > 0 ? self.n_audio_out : 1];
+ float* const in_buf = alloc_audio_buffer(self.n_audio_in);
+ float* const out_buf = alloc_audio_buffer(self.n_audio_out);
self.instance = lilv_plugin_instantiate(self.plugin, in_fmt.samplerate, NULL);
for (uint32_t p = 0, i = 0, o = 0; p < n_ports; ++p) {
if (self.ports[p].type == TYPE_CONTROL) {
@@ -341,13 +347,16 @@ main(int argc, char** argv)
read/write from/to sndfile. */
lilv_instance_activate(self.instance);
+ int st = 0;
while (sread(self.in_file, in_fmt.channels, in_buf, self.n_audio_in)) {
lilv_instance_run(self.instance, 1);
if (sf_writef_float(self.out_file, out_buf, 1) != 1) {
- return fatal(&self, 9, "Failed to write to output file\n");
+ st = fatal(&self, 9, "Failed to write to output file\n");
}
}
lilv_instance_deactivate(self.instance);
- return cleanup(0, &self);
+ free(out_buf);
+ free(in_buf);
+ return st ? st : cleanup(0, &self);
}