Skip to content

Commit

Permalink
utils: Remove needless NULL check
Browse files Browse the repository at this point in the history
This Ruby C extension does not need to pass valgrind check.
We can remove them without this check because free(3) is safe for
passing NULL.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Jul 31, 2024
1 parent 616a664 commit 89c429e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions ext/winevt/winevt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,8 @@ static int ExpandSIDWString(PSID sid, CHAR **out_expanded)

*out_expanded = strdup(formatted);

if (domain != NULL) {
free(domain);
}
if (account != NULL) {
free(account);
}
free(domain);
free(account);
RB_ALLOCV_END(vformatted);


Expand All @@ -689,12 +685,8 @@ static int ExpandSIDWString(PSID sid, CHAR **out_expanded)
err = GetLastError();

RB_ALLOCV_END(vformatted);
if (domain != NULL) {
free(domain);
}
if (account != NULL) {
free(account);
}
free(domain);
free(account);
raise_system_error(rb_eRuntimeError, err);
}

Expand Down

0 comments on commit 89c429e

Please sign in to comment.