Skip to content

remove unnecessary NULL checks before free()#654

Merged
bk138 merged 1 commit intoLibVNC:masterfrom
RokerHRO:no-check-for-null-for-free
Feb 27, 2025
Merged

remove unnecessary NULL checks before free()#654
bk138 merged 1 commit intoLibVNC:masterfrom
RokerHRO:no-check-for-null-for-free

Conversation

@RokerHRO
Copy link
Copy Markdown
Contributor

I found several unnecessary checks for NULL before call of free().

I removed them.

I don't remove the check in code that sets the pointer to NULL after the free:

if(p)
{
    free(p);
    p = NULL;
}

Additionally I found a questionable macro FREE_IF in main.c which seems to be a shortcut to free (with unnecessary NULL check) a member of struct screen. I renamed it to FREE_SCREEN_MEMBER to reflect its purpose better, but it is used only twice, so I'd favor to remove this macro completely.

@bk138 bk138 merged commit 0958967 into LibVNC:master Feb 27, 2025
12 checks passed
@bk138
Copy link
Copy Markdown
Member

bk138 commented Feb 27, 2025

Thank you very much!

@RokerHRO RokerHRO deleted the no-check-for-null-for-free branch February 27, 2025 12:15
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.

2 participants