diff options
author | Simon Ser <contact@emersion.fr> | 2022-04-26 09:43:54 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-04-28 10:09:50 +0200 |
commit | 6c350799b22ddc5cb89467c95692437bbf0116b9 (patch) | |
tree | 4559c68cb117d9c044e79fb0fbb7453042538375 /util | |
parent | 54653b5d95935e379e26db5518456a66384b5405 (diff) |
Zero-initialize structs in init functions
Ensures there is no field left to its previous undefined value after
calling an init function.
Diffstat (limited to 'util')
-rw-r--r-- | util/addon.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/util/addon.c b/util/addon.c index 395a8df6..c9b373a7 100644 --- a/util/addon.c +++ b/util/addon.c @@ -1,9 +1,11 @@ #include <assert.h> #include <stdlib.h> +#include <string.h> #include <wayland-server-core.h> #include <wlr/util/addon.h> void wlr_addon_set_init(struct wlr_addon_set *set) { + memset(set, 0, sizeof(*set)); wl_list_init(&set->addons); } @@ -18,6 +20,7 @@ void wlr_addon_set_finish(struct wlr_addon_set *set) { void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set, const void *owner, const struct wlr_addon_interface *impl) { assert(owner && impl); + memset(addon, 0, sizeof(*addon)); struct wlr_addon *iter; wl_list_for_each(iter, &set->addons, link) { if (iter->owner == addon->owner && iter->impl == addon->impl) { |