summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-09-02 22:44:42 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-09-02 22:44:42 -0700
commit3b0c9a6b3ebedc6d464262de4962a235b66b9c9b (patch)
tree3f841377290478816d1299024c22557c18d1bd12
parent569f87aa166eb8a62190acb24ff8f34515b16c7d (diff)
til: verify module and setup creator match
til_module_create_contexts() currently supplies the til_module_t* independent from the til_setup_t*, but since the addition of til_setup_t.creator, we actually get the module from the setup as well. So let's at least assert that they match, since it'd be a real problem if a setup from a foreign creator somehow got here. It's tempting to refactor to just derive the module from the setup altogether and stop passing that around separately, but that kind of sucks as-is because til_setup_t is used by more than just rendering modules. It makes me lean towards deprecating til_setup_t.creator and instead having the various til_setup_t users subclass it with their own types like til_fb_setup_t and til_module_setup_t which each get typed creators, then pass those around. It's starting to smell like over-engineering, let's just roll with the assert.
-rw-r--r--src/til.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/til.c b/src/til.c
index fcc2549..e1f15cc 100644
--- a/src/til.c
+++ b/src/til.c
@@ -322,6 +322,7 @@ int til_module_create_contexts(const til_module_t *module, til_stream_t *stream,
assert(module);
assert(setup); /* we *always* want a setup, even if the module has no setup() method - for the path */
+ assert(module == setup->creator); /* these should never differ */
assert(n_contexts > 0);
assert(res_contexts);
© All Rights Reserved