-
Notifications
You must be signed in to change notification settings - Fork 262
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
Cleanup some of the ncgen memory problems identified by Ed #558
Conversation
ncgen/bytebuffer.c
Outdated
@@ -250,7 +250,7 @@ bbTailpeek(Bytebuffer* bb, char* pelem) | |||
char* | |||
bbDup(const Bytebuffer* bb) | |||
{ | |||
char* result = (char*)emalloc(bb->length+1); | |||
char* result = (char*)malloc(bb->length+1); |
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 never cast the result of mallocs. See https://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc for reasons.
Does this fix all the ncgen memory leaks? Quick work! ;-) |
Only some of them. The global metadata and data trees created during the parse |
I find the arguments against casting unpersuasive. But frankly |
Looks great, checking on ARM and Windows now. |
Given the common wisdom of casting from 'malloc' I would agree with Dennis that a single post asserting differently is unpersuasive. But if he is unconcerned, so am I, and we can backtrack if an issue arises. |
Actually wasn't suggesting that he take all the malloc casts away in this case, just offering the observation for future consideration. |
Seeing a handful of failures on OSX, still testing windows and ARM. The failures can be seen here: The failure described below seems to be common amongst the tests:
Update, 32-bit Windows tests passed. Will update as ARM and 64-bit Windows tests run. |
Update: 64-bit Windows tests also passed. |
As did ARM. This issue appears to be OSX specific. I will see if I can figure out what's going on. |
ncgen/main.c
Outdated
@@ -299,8 +296,7 @@ main( | |||
derror("%s: output language is null", progname); | |||
return(1); | |||
} | |||
lang_name = (char*) emalloc(strlen(optarg)+1); | |||
(void)strcpy(lang_name, optarg); | |||
lang_name = estrdup(optarg); |
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.
This line is returning "" on OSX, for reasons I'm not sure about yet. Is there a problem with using the previous behavior for determining the language? Because "" is being returned we are falling through to "language not implemented" and then nullfree is crashing because it is trying to free memory lang_name
that has not been allocated. We can fix that by checking for a length-zero lang_name
before freeing, but that doesn't solve the output language not implemented
problem.
Not sure if tagging people is required for these individual comments, so tagging @DennisHeimbigner just to be sure.
Was able to fix the issue above, but running into a problem with ref_typescope test in |
This pull request introduces 1 alert and fixes 10 when merging ee7bbb2 into e595a8c - view on lgtm.com new alerts:
fixed alerts:
Comment posted by lgtm.com |
This pull request introduces 1 alert when merging ee0086f into 51de066 - view on lgtm.com new alerts:
Comment posted by lgtm.com |
This code should be merged already, double-checking. |
No description provided.