[Commits] [wesnoth/wesnoth] 5f7771: wml_message: fix possible nullpointer dereference.

GitHub noreply at github.com
Tue Jul 25 23:58:28 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 5f7771acd4ae359b15a14686b033d04e4709bc5c
      https://github.com/wesnoth/wesnoth/commit/5f7771acd4ae359b15a14686b033d04e4709bc5c
  Author: Matthias Krüger <matthias.krueger at famsik.de>
  Date:   2017-06-17 (Sat, 17 Jun 2017)

  Changed paths:
    M src/gui/dialogs/wml_message.cpp

  Log Message:
  -----------
  wml_message: fix possible nullpointer dereference.

This was found by cppcheck:
[src/gui/dialogs/wml_message.cpp:174] -> [src/gui/dialogs/wml_message.cpp:177]: (warning) Either the condition 'right' is redundant or there is possible null pointer dereference: right.

Code was as follows:

	if(left && !right) {
		dlg.reset(new wml_message_left(title, message, left->portrait, left->mirror));
	} else if(!left && right) {
		dlg.reset(new wml_message_right(title, message, right->portrait, right->mirror));
	} else {
		dlg.reset(new wml_message_double(title, message, left->portrait, left->mirror, right->portrait, right->mirror));
	}

left  right  => branch taken
 T	T         else {}
 T	F	  if {}
 F	T         elseif {}
 F	F         else {}   // we could possibly access left->foo and right->foo here

Make  else {}  into an explicit   else if (right && left) {}


  Commit: 163749337984eb4392b6da2234185391a8c8cdd1
      https://github.com/wesnoth/wesnoth/commit/163749337984eb4392b6da2234185391a8c8cdd1
  Author: Matthias Krüger <matthias.krueger at famsik.de>
  Date:   2017-06-17 (Sat, 17 Jun 2017)

  Changed paths:
    M src/ai/configuration.hpp

  Log Message:
  -----------
  ai/configuration.hpp: parse_side_config(): make arguments in declaration and definition the same.
Found by cppcheck:
[src/ai/configuration.hpp:108] -> [src/ai/configuration.cpp:178]: (warning) Function 'parse_side_config' argument order different: declaration 'side, cfg, parsed_cfg' definition 'side, original_cfg, cfg'

Rename arguments in declaration (configuration.hpp) from   'side, cfg, parsed_cfg'  to  'side, original_cfg, cfg'.


  Commit: cca277634311add76d5506cc1c7499db25f386e5
      https://github.com/wesnoth/wesnoth/commit/cca277634311add76d5506cc1c7499db25f386e5
  Author: Celtic Minstrel <CelticMinstrel at users.noreply.github.com>
  Date:   2017-07-25 (Tue, 25 Jul 2017)

  Changed paths:
    M src/ai/configuration.hpp
    M src/gui/dialogs/wml_message.cpp

  Log Message:
  -----------
  Merge pull request #1799 from matthiaskrgr/cppcheck

address two cppcheck findings


Compare: https://github.com/wesnoth/wesnoth/compare/f1fe86ab5f89...cca277634311


More information about the Commits mailing list