Fix NPE in endCall when deviceId is null

HangupMessage requires a non-null deviceId, but deviceId is only set
once the remote peer's offer is received. If the call ends before the
offer arrives (e.g. tunnel fails to spawn), deviceId is null and the
HangupMessage constructor throws a NullPointerException.

Guard the hangup send with a deviceId != null check so the protocol
message is only sent when there is a known remote device to address.
This commit is contained in:
neagix 2026-06-11 17:25:13 +02:00 committed by neagix
parent 6bef205b3f
commit c9691849be

View File

@ -706,8 +706,11 @@ public class CallManager implements AutoCloseable {
fireCallEvent(state, reason);
logger.debug("Call {} ended: {}", callIdUnsigned(callId), reason);
// Send Signal protocol hangup to remote peer (unless they initiated the end)
if (!"remote_hangup".equals(reason)
// Send Signal protocol hangup to remote peer (unless they initiated the end).
// Skip if deviceId is null: no offer was exchanged yet (e.g. tunnel failed to spawn),
// so there is no remote device to notify.
if (state.deviceId != null
&& !"remote_hangup".equals(reason)
&& !"rejected".equals(reason)
&& !"remote_busy".equals(reason)
&& !"ringrtc_hangup".equals(reason)) {