-
Notifications
You must be signed in to change notification settings - Fork 60
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
Conversation
There was a problem hiding this 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!
src/lib/ec_glob.c
Outdated
@@ -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); \ |
There was a problem hiding this comment.
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.
src/lib/ec_glob.c
Outdated
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); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
SGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Static analysis found a number of leaks through the use of the convenience macros.