fix crash when cancelling access token dialog

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

ivanhoe
grim/purple-spasm
default
grim
fix crash when cancelling access token dialog


Summary
fix crash when cancelling access token dialog
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
Review request changed

Change Summary:

Do simple NULL check instead of calling g_return_if_fail.

Commits:

Summary
-
fix crash when cancelling access token dialog
+
fix crash when cancelling access token dialog

Diff:

Revision 2 (+6)

Show changes

Loading...