aboutsummaryrefslogtreecommitdiffstats
path: root/lv2
diff options
context:
space:
mode:
Diffstat (limited to 'lv2')
-rw-r--r--lv2/atom/forge-overflow-test.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lv2/atom/forge-overflow-test.c b/lv2/atom/forge-overflow-test.c
index daad3f8..b9beacc 100644
--- a/lv2/atom/forge-overflow-test.c
+++ b/lv2/atom/forge-overflow-test.c
@@ -27,8 +27,9 @@
static int
test_string_overflow(void)
{
- static const size_t max_chars = 15;
- static const size_t capacity = 8 + max_chars + 1;
+#define MAX_CHARS 15
+
+ static const size_t capacity = sizeof(LV2_Atom_String) + MAX_CHARS + 1;
static const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
uint8_t* buf = (uint8_t*)malloc(capacity);
@@ -37,7 +38,7 @@ test_string_overflow(void)
lv2_atom_forge_init(&forge, &map);
// Check that writing increasingly long strings fails at the right point
- for (size_t count = 0; count < max_chars; ++count) {
+ for (size_t count = 0; count < MAX_CHARS; ++count) {
lv2_atom_forge_set_buffer(&forge, buf, capacity);
const LV2_Atom_Forge_Ref ref =
@@ -49,7 +50,7 @@ test_string_overflow(void)
// Failure writing to an exactly full forge
LV2_Atom_Forge_Ref ref = 0;
- if ((ref = lv2_atom_forge_string(&forge, str, max_chars + 1))) {
+ if ((ref = lv2_atom_forge_string(&forge, str, MAX_CHARS + 1))) {
return test_fail("Successfully wrote past end of buffer\n");
}
@@ -66,7 +67,7 @@ test_string_overflow(void)
static int
test_literal_overflow(void)
{
- static const size_t capacity = 16 + 2;
+ static const size_t capacity = sizeof(LV2_Atom_Literal) + 2;
uint8_t* buf = (uint8_t*)malloc(capacity);
LV2_URID_Map map = { NULL, urid_map };