From 13e29c64f39239bbed55d94033fcc2cee785ada3 Mon Sep 17 00:00:00 2001 From: Kp Date: Mon, 28 Jun 2021 03:37:51 +0000 Subject: [PATCH] In debug builds, initialize newmenu_item type,text to poison values This improves the chance that an unset value will abort rather than displaying strange results. Release builds are unchanged. --- common/main/newmenu.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/main/newmenu.h b/common/main/newmenu.h index 1acac762d..687b49791 100644 --- a/common/main/newmenu.h +++ b/common/main/newmenu.h @@ -209,13 +209,21 @@ public: ? &nm_private.input : nullptr; } - char *text; // The text associated with this item. + char *text +#ifndef NDEBUG + = reinterpret_cast(UINTPTR_MAX); +#endif + ; // The text associated with this item. int value; // For checkboxes and radio buttons, this is 1 if marked initially, else 0 // The rest of these are used internally by by the menu system, so don't set 'em!! short x, y; short w, h; uint8_t right_offset; - nm_type type; // What kind of item this is, see NM_TYPE_????? defines + nm_type type +#ifndef NDEBUG + = static_cast(UINT8_MAX); +#endif + ; // What kind of item this is, see NM_TYPE_????? defines union nm_type_specific_data { nm_type_specific_data() : input{{nullptr, 0, 0}}