Skip to content

fix potential null deref reported by static analyzer#460

Open
danix800 wants to merge 2 commits intojordansissel:masterfrom
danix800:fix/potential-null-deref
Open

fix potential null deref reported by static analyzer#460
danix800 wants to merge 2 commits intojordansissel:masterfrom
danix800:fix/potential-null-deref

Conversation

@danix800
Copy link

Calling 'xdo_translate_window_with_sizehint' from 'xdo_set_window_size' shows both 'width_ret' and 'height_ret' could be null. Storing values into these pointers could be a null deref.

If these two pointers couldn't be null, then the condition in the following

  if (width_ret != NULL) {
    *width_ret = width;
  }

  if (height_ret != NULL) {
    *height_ret = height;
  }

is redundant, this is a reversed null checking.

danix800 added 2 commits May 24, 2024 11:02
Calling 'xdo_translate_window_with_sizehint' from 'xdo_set_window_size'
shows both 'width_ret' and 'height_ret' could be null. Storing values
into these pointers could be a null deref.

If these two pointers couldn't be null, then the condition in the following

  if (width_ret != NULL) {
    *width_ret = width;
  }

  if (height_ret != NULL) {
    *height_ret = height;
  }

is redundant, this is a reversed null checking.
@danix800 danix800 force-pushed the fix/potential-null-deref branch from 62fd15b to c3d014c Compare May 24, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant