From 3b0c9a6b3ebedc6d464262de4962a235b66b9c9b Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 2 Sep 2023 22:44:42 -0700 Subject: 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. --- src/til.c | 1 + 1 file changed, 1 insertion(+) 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); -- cgit v1.2.3