Skip to content
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

lib/ec_glob: plug leak of nums utarray #109

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

chergert
Copy link
Contributor

Static analysis found a number of leaks through the use of the convenience macros.

Copy link
Member

@xuhdev xuhdev left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@@ -53,16 +53,20 @@ static const UT_icd ut_int_pair_icd = {sizeof(int_pair),NULL,NULL,NULL};
#define STRING_CAT(p, string, end) do { \
size_t string_len = strlen(string); \
assert(end > p); \
if (string_len >= (size_t)(end - p)) \
if (string_len >= (size_t)(end - p)) { \
utarray_free(nums); \
Copy link
Member

Choose a reason for hiding this comment

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

I would say goto cleanup is more preferable, which also frees any pcre2 handles if present.

strcat(p, string); \
p += string_len; \
} while(0)

/* safely add a char to a string then move the pointer to the end */
#define ADD_CHAR(string, new_chr, end) do { \
if (string + 1 >= end) \
if (string + 1 >= end) { \
utarray_free(nums); \
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@chergert
Copy link
Contributor Author

SGTM

src/lib/ec_glob.c Show resolved Hide resolved
src/lib/ec_glob.c Show resolved Hide resolved
Copy link
Member

@xuhdev xuhdev left a comment

Choose a reason for hiding this comment

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

Thanks!

@xuhdev xuhdev merged commit 02ac2b7 into editorconfig:master Jun 12, 2024
11 checks passed
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