Changeset - r22901:444c689660a1
[Not reviewed]
master
0 1 0
Jonathan G Rennison - 6 years ago 2018-06-06 07:22:58
j.g.rennison@gmail.com
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.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/misc_gui.cpp
Show inline comments
 
@@ -653,13 +653,13 @@ struct TooltipsWindow : public Window
 
	TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc)
 
	{
 
		this->parent = parent;
 
		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;
 

	
 
		this->InitNested();
 

	
 
		CLRBITS(this->flags, WF_WHITE_BORDER);
0 comments (0 inline, 0 general)