Ticket #48379

sdl2: real_units_report_dialog_update() pbuf NULL dereference

Open Date: 2023-07-10 12:59 Last Update: 2023-07-16 17:35

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
2

Details

S3_1, clang analyzer:

../../../../src/client/gui-sdl2/repodlgs.c:946:25: warning: Access to field 'id' results in a dereference of a null pointer (loaded from variable 'pbuf') [core.NullDereference]
          if ((MAX_ID - pbuf->id) == utype_number(i)) {
                        ^~~~~~~~

Seems actual bug to me. pbuf gets assigned from pwidget which has been assigned (initially) from units_dlg->end_active_widget_list, that might has no value assigned at all since fc_calloc() set it NULL. That can happen when the player has no units at all.

Ticket History (3/5 Histories)

2023-07-10 12:59 Updated by: cazfi
  • New Ticket "sdl2: real_units_report_dialog_update() pbuf NULL dereference" created
2023-07-10 13:18 Updated by: cazfi
  • Owner Update from (None) to cazfi
  • Resolution Update from None to Accepted
Comment

Patches for all branches, including S2_6, attached.

2023-07-16 17:35 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login