Skip to content

tree-wide: Do not manually check for NULL before calling free() #19063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TimWolla
Copy link
Member

@TimWolla TimWolla commented Jul 7, 2025

Changes performed with Coccinelle:

@@
expression e;
@@

- if (e) {
	efree(e);
- }

@@
expression e;
@@

- if (e) {
	efree(e);
	e = NULL;
- }

@@
expression e;
@@

- if (e) {
	free(e);
- }

@@
expression e;
@@

- if (e) {
	free(e);
	e = NULL;
- }

@@
expression e, e2;
@@

- if (e) {
	pefree(e, e2);
- }

@@
expression e, e2;
@@

- if (e) {
	pefree(e, e2);
	e = NULL;
- }

Changes performed with Coccinelle:

    @@
    expression e;
    @@

    - if (e) {
    	efree(e);
    - }

    @@
    expression e;
    @@

    - if (e) {
    	efree(e);
    	e = NULL;
    - }

    @@
    expression e;
    @@

    - if (e) {
    	free(e);
    - }

    @@
    expression e;
    @@

    - if (e) {
    	free(e);
    	e = NULL;
    - }

    @@
    expression e, e2;
    @@

    - if (e) {
    	pefree(e, e2);
    - }

    @@
    expression e, e2;
    @@

    - if (e) {
    	pefree(e, e2);
    	e = NULL;
    - }
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor CS nits but looks nice :)

Comment on lines +150 to 151
efree((*session)->a); \
(*session)->a = NULL; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
efree((*session)->a); \
(*session)->a = NULL; \
efree((*session)->a); \
(*session)->a = NULL; \

Comment on lines +363 to +364
/* malloc was used to store value */
efree(dbuf);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* malloc was used to store value */
efree(dbuf);
/* malloc was used to store value */
efree(dbuf);

Comment on lines 1120 to 1122
efree(error);

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
efree(error);
}
efree(error);
}

@devnexen
Copy link
Member

devnexen commented Jul 7, 2025

the title caught me :) so not just free but zendmm api flavors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants