[Scummvm-cvs-logs] SF.net SVN: scummvm:[44920] scummvm/trunk/gui/ListWidget.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Oct 11 15:44:19 CEST 2009


Revision: 44920
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44920&view=rev
Author:   lordhoto
Date:     2009-10-11 13:44:19 +0000 (Sun, 11 Oct 2009)

Log Message:
-----------
Hopefully avoiding an assert in the MSVC debug CRT library when entering an umlaut in the launcher.

It's a bad idea to cast a parameter to the "is*" functions from ctype.h to "char",
since "char" might be signed and the "is*" functions are defined to only accept
input which fits "unsigned char" or equals EOF. In this concrete example the value
of "state.ascii" is > 0x7F, thus becomes negative after the cast to "char", which
violates the parameter rules of "isprint".

Sadly it seems this is not the only place in our code, which does pass a possibly
signed parameter to an "is*" function. We might either want to change all code to
only pass an unsigned char value, change the code to do parameter validation or
fix it in another way.

Modified Paths:
--------------
    scummvm/trunk/gui/ListWidget.cpp

Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2009-10-11 13:35:20 UTC (rev 44919)
+++ scummvm/trunk/gui/ListWidget.cpp	2009-10-11 13:44:19 UTC (rev 44920)
@@ -286,7 +286,7 @@
 	bool dirty = false;
 	int oldSelectedItem = _selectedItem;
 
-	if (!_editMode && isprint((char)state.ascii)) {
+	if (!_editMode && isprint((unsigned char)state.ascii)) {
 		// Quick selection mode: Go to first list item starting with this key
 		// (or a substring accumulated from the last couple key presses).
 		// Only works in a useful fashion if the list entries are sorted.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list