The International Simutrans Forum

 

Author Topic: Array out of bounds in wayobj  (Read 128 times)

0 Members and 1 Guest are viewing this topic.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4506
  • Languages: EN, DE, AT
Array out of bounds in wayobj
« on: January 06, 2019, 12:02:36 PM »
I get the following compiler complaint:
Code: [Select]
obj/../descriptor/way_obj_desc.h: In member function 'virtual image_id wayobj_t::get_image() const':
obj/../descriptor/way_obj_desc.h:64:52: warning: array subscript is above array bounds [-Warray-bounds]
    return imglist->get_image_id( ribi_to_extra[ribi]+16+(nw*5) );
The reason is the following: in wayobj_t::get_image the method get_crossing_image_id is called with parameter ``dir'' if dir is larger than 16, which is out-of-bounds. Is there some masking missing?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5387
  • Languages: EN, NO
Re: Array out of bounds in wayobj
« Reply #1 on: January 06, 2019, 04:26:18 PM »
The code in question was committed by prissi in August along with changes related to sound. The commit message only mentions sound. I suspect that get_crossing_image_id is unfinished code that was committed by mistake.