Skip to content

Commit

Permalink
Make client more robust against inconsistent state
Browse files Browse the repository at this point in the history
If during message handling we somehow end up in a situation
where no ClientUser is registered or g.uiSession is not set
we end up with pSelf as a null pointer. Dereferncing that
crashes the application.

Similar to other objects we retrieve for message processing
this patch modified the macro to log and bail if we encounter
this situation instead of crashing.

One drawback of this patch is that it might make state
corruption caused by client bugs less visible to us because
we no longer receive crash reports on them while the client
functionality could still be degraded severly.
  • Loading branch information
hacst committed Oct 27, 2019
1 parent 856eefa commit 44b5b78
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/mumble/Messages.cpp
Expand Up @@ -45,8 +45,11 @@
}

#define SELF_INIT \
ClientUser *pSelf = ClientUser::get(g.uiSession);

ClientUser *pSelf = ClientUser::get(g.uiSession); \
if (! pSelf) { \
qWarning("MainWindow: Received message outside outside of session (sid %d).", g.uiSession); \
return; \
}

void MainWindow::msgAuthenticate(const MumbleProto::Authenticate &) {
}
Expand Down Expand Up @@ -262,8 +265,7 @@ void MainWindow::msgUDPTunnel(const MumbleProto::UDPTunnel &) {

void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
ACTOR_INIT;
SELF_INIT;

ClientUser* pSelf = ClientUser::get(g.uiSession);
ClientUser *pDst = ClientUser::get(msg.session());
Channel *channel = NULL;

Expand Down

0 comments on commit 44b5b78

Please sign in to comment.