pjsip / pjproject

PJSIP project
http://www.pjsip.org
GNU General Public License v2.0
2.07k stars 786 forks source link

Fix to compile error in on_make_call_med_tp_complete while accessing calls array with invalid call id. #4144

Closed amubiera closed 2 weeks ago

amubiera commented 2 weeks ago

Fixes compile warning/error on certain GCC versions using optimized -O2 builds:

pjsip/src/pjsua-lib/pjsua_call.c: In function 'on_make_call_med_tp_complete':
pjsip/src/pjsua-lib/pjsua_call.c:436:40: warning: array subscript -1 is below array bounds of 'pjsua_call[3]' [-Warray-bounds=]
  436 |     pjsua_call *call = &pjsua_var.calls[call_id];

call_id being invalid at this point should be impossible, but a particular ARM GCC version 13.2.1 does not detect that if (call_id == PJSUA_INVALID_ID) on line 861 of pjsua_call_make_call makes it impossible.