fix crash when cancelling access token dialog

Review Request #1506 — Created June 21, 2022 and submitted

Information

grim/purple-spasm
default

Reviewers

fix crash when cancelling access token dialog

 
Summary ID Author
fix crash when cancelling access token dialog
3a21231469e65085a3c93a61345c54af06094d03 ivanhoe
Description From Last Updated

The null check should also be in the cancel handler. The free function should in theory just do nothing if …

grimgrim
grim
  1. 
      
  2. src/spasm-chat.c (Diff revision 1)
     
     

    The null check should also be in the cancel handler.

    The free function should in theory just do nothing if it's NULL, but this change makes it print out a GWarning

    1. I don't understand what you mean.

      The null check should also be in the cancel handler.

      Do you mean spasm_access_token_cancel_cb? Because we only have the SpasmAccount there and I don't think it would make sense to null check its chat member before passing it to spasm_account_free.

      The free function should in theory just do nothing if it's NULL, but this change makes it print out a GWarning

      Before the free function is called on chat, members of chat are attempted to be unref'd which crashes if chat is 0. So the null check is needed.

    2. I don't understand what you mean.

      The null check should also be in the cancel handler.

      I meant whatever was calling spams_chat_service_free, although arguably, that's not necessary with my next comment.

      Before the free function is called on chat, members of chat are attempted to be unref'd which crashes if chat is 0. So the null check is needed.

      Yes a NULL check is needed, but g_return_if_fail prints a g_warning where as

      if(chat == NULL) {
          return;
      }
      

      Does not, and therefore does nothing.

  3. 
      
ivanhoe
grim
  1. Ship It!
  2. Nice work, thanks!!

  3. 
      
grim
Review request changed

Status: Closed (submitted)

Loading...