From 71450881fc9343430a1558193b4f4c9eb888a73d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 6 Jun 2018 08:22:58 +0100 Subject: Codechange: Avoid call to memcpy using null pointer in TooltipsWindow constructor Strictly speaking, calling memcpy with src as a nullptr is undefined behaviour and the optimiser is entitled to delete any null ptr checks which occur afterwards. This removes the warning emitted by UndefinedBehaviorSantizer. --- src/misc_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/misc_gui.cpp') diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 5252832b5..dd7541062 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -656,7 +656,7 @@ struct TooltipsWindow : public Window this->string_id = str; assert_compile(sizeof(this->params[0]) == sizeof(params[0])); assert(paramcount <= lengthof(this->params)); - memcpy(this->params, params, sizeof(this->params[0]) * paramcount); + if (paramcount > 0) memcpy(this->params, params, sizeof(this->params[0]) * paramcount); this->paramcount = paramcount; this->close_cond = close_tooltip; -- cgit v1.2.3-54-g00ecf