The International Simutrans Forum

 

Author Topic: Fix for potential crash when opening gameinfo window  (Read 426 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 249
Fix for potential crash when opening gameinfo window
« on: May 03, 2020, 03:20:35 PM »
This fixes a potential crash when opening the game info window via the "play online" button. If the language iso is for example only 2 characters, the memcpy call copies more characters than needed.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10635
  • Languages: De,EN,JP
Re: Fix for potential crash when opening gameinfo window
« Reply #1 on: May 05, 2020, 03:08:03 AM »
Simutrans cannot handle language codes larger than 2 letters with the current system anyway, also limited by the translator. Moreover, if you do a malloc, the smallest chunk you can get (typically) is 256 bytes, hence this error should not occur.

Nevertheless, using tstrncpy is indeed better. In in r9064.