diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2018-06-06 08:22:58 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2018-06-07 09:49:26 +0100 |
commit | 71450881fc9343430a1558193b4f4c9eb888a73d (patch) | |
tree | 56ce108637748a1e2a72985c204c8d92433e6b2b /src | |
parent | cd966f3810e21ab24b81379ae0837d95376d91b4 (diff) | |
download | openttd-71450881fc9343430a1558193b4f4c9eb888a73d.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/misc_gui.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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; |