aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-10-06 13:58:20 -0400
committerDavid Robillard <d@drobilla.net>2024-10-06 13:58:20 -0400
commite81bab5250071e489f2577e33fccd5f7b8077fd2 (patch)
tree77e23a899f310ed8dde7639a7289f51ea4b0c0d8 /test
parent5309d0fcc9ef1a01ce9d0e3631ae45eb86a28740 (diff)
downloadlv2-e81bab5250071e489f2577e33fccd5f7b8077fd2.tar.xz
Cleanly abort on allocation failure in atom tests
Really just to avoid the common leaking realloc pattern recognized by static checkers.
Diffstat (limited to 'test')
-rw-r--r--test/atom_test_utils.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/atom_test_utils.c b/test/atom_test_utils.c
index e7d45d0..bffa2ea 100644
--- a/test/atom_test_utils.c
+++ b/test/atom_test_utils.c
@@ -1,12 +1,15 @@
// Copyright 2012-2018 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
+#undef NDEBUG
+
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#include "lv2/atom/util.h"
#include "lv2/log/log.h"
#include "lv2/urid/urid.h"
+#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -32,8 +35,11 @@ urid_map(LV2_URID_Map_Handle handle, const char* uri)
}
}
- uris = (char**)realloc(uris, ++n_uris * sizeof(char*));
- uris[n_uris - 1] = copy_string(uri);
+ char** const new_uris = (char**)realloc(uris, (n_uris + 1) * sizeof(char*));
+ assert(new_uris);
+
+ uris = new_uris;
+ uris[n_uris++] = copy_string(uri);
return n_uris;
}