aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-16 16:54:00 +0100
committerDavid Robillard <d@drobilla.net>2020-12-16 16:54:00 +0100
commit326ecdf238921dc12645f2c31f4882499a387aa0 (patch)
tree124fc0bd4c96204f7587ec20bdde70221f19ca24
parentbf4ceb41a88f9adcaa5ec77db6e37f904c43d158 (diff)
downloadlv2-326ecdf238921dc12645f2c31f4882499a387aa0.tar.xz
Add assertions for atom buffer sizes
This avoids warnings about potential null pointer dereferences, which is true, but in this case the buffer are static so it's really a programming error if there is ever an overrun.
-rw-r--r--plugins/eg-sampler.lv2/sampler_ui.c5
-rw-r--r--plugins/eg-scope.lv2/examploscope_ui.c8
2 files changed, 13 insertions, 0 deletions
diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c
index 8dddd4c..3070828 100644
--- a/plugins/eg-sampler.lv2/sampler_ui.c
+++ b/plugins/eg-sampler.lv2/sampler_ui.c
@@ -89,6 +89,8 @@ on_file_set(GtkFileChooserButton* widget, void* handle)
LV2_Atom* msg = (LV2_Atom*)write_set_file(&ui->forge, &ui->uris,
filename, strlen(filename));
+ assert(msg);
+
ui->write(ui->controller, 0, lv2_atom_total_size(msg),
ui->uris.atom_eventTransfer,
msg);
@@ -310,6 +312,9 @@ instantiate(const LV2UI_Descriptor* descriptor,
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(
&ui->forge, &frame, 0, ui->uris.patch_Get);
+
+ assert(msg);
+
lv2_atom_forge_pop(&ui->forge, &frame);
ui->write(ui->controller, 0, lv2_atom_total_size(msg),
diff --git a/plugins/eg-scope.lv2/examploscope_ui.c b/plugins/eg-scope.lv2/examploscope_ui.c
index 48ffec4..32584a4 100644
--- a/plugins/eg-scope.lv2/examploscope_ui.c
+++ b/plugins/eg-scope.lv2/examploscope_ui.c
@@ -105,6 +105,8 @@ send_ui_state(LV2UI_Handle handle)
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(
&ui->forge, &frame, 0, ui->uris.ui_State);
+ assert(msg);
+
// msg[samples-per-pixel] = integer
lv2_atom_forge_key(&ui->forge, ui->uris.ui_spp);
lv2_atom_forge_int(&ui->forge, ui->stride);
@@ -137,6 +139,9 @@ send_ui_disable(LV2UI_Handle handle)
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(
&ui->forge, &frame, 0, ui->uris.ui_Off);
+
+ assert(msg);
+
lv2_atom_forge_pop(&ui->forge, &frame);
ui->write(ui->controller,
0,
@@ -161,6 +166,9 @@ send_ui_enable(LV2UI_Handle handle)
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(
&ui->forge, &frame, 0, ui->uris.ui_On);
+
+ assert(msg);
+
lv2_atom_forge_pop(&ui->forge, &frame);
ui->write(ui->controller,
0,