• R/O
  • SSH

zandronum-sandbox-stable: Commit


Commit MetaInfo

Revision1d49b488e92797649bc9c007556393098f671152 (tree)
Time2023-03-06 07:05:15
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

Fixed a case of undefined behaviour caused by comparing two ColumnValue objects holding strings.

Change Summary

Incremental Difference

diff -r ec4ffe43cf9c -r 1d49b488e927 src/scoreboard.cpp
--- a/src/scoreboard.cpp Sun Mar 05 12:11:50 2023 -0500
+++ b/src/scoreboard.cpp Sun Mar 05 17:05:15 2023 -0500
@@ -402,7 +402,18 @@
402402 return ( GetValue<float>( ) == Other.GetValue<float>( ));
403403
404404 case COLUMNDATA_STRING:
405- return ( strcmp( GetValue<const char *>( ), Other.GetValue<const char *>( )) == 0 );
405+ {
406+ const char *pszString1 = GetValue<const char *>( );
407+ const char *pszString2 = Other.GetValue<const char *>( );
408+
409+ // [AK] If one of the strings is NULL, then return either true if
410+ // both of them are NULL (i.e. pszString1 and pszString2 are equal),
411+ // or false otherwise.
412+ if (( pszString1 == NULL ) || ( pszString2 == NULL ))
413+ return ( pszString1 == pszString2 );
414+
415+ return ( strcmp( pszString1, pszString2 ) == 0 );
416+ }
406417
407418 case COLUMNDATA_COLOR:
408419 return ( GetValue<PalEntry>( ) == Other.GetValue<PalEntry>( ));
Show on old repository browser