src: fix mismatched delete[] in src/node_file.cc#1092
Merged
bnoordhuis merged 2 commits intonodejs:v1.xfrom Mar 7, 2015
Merged
src: fix mismatched delete[] in src/node_file.cc#1092bnoordhuis merged 2 commits intonodejs:v1.xfrom
bnoordhuis merged 2 commits intonodejs:v1.xfrom
Conversation
Member
|
No open issues about it yet. |
Member
There was a problem hiding this comment.
Fix a bad delete of a pointer that was allocated with placement new. Casting the pointer was not the right solution because there was at least one non-placement new constructor call. This commit rewrites FSReqWrap to be more explicit about ownership of the auxiliary data and removes a number of egregious const_casts. The ASYNC_DEST_CALL macro also gets significantly slimmed down. PR-URL: nodejs#1092 Reviewed-By: Fedor Indutny <fedor@indutny.com>
The SYNC_CALL macro returns on error, bypassing the delete[] call. Mea culpa, it looks like I introduced this memory leak back in 2013, in commit d2b80b8 ("src: clean up FSReqWrap"). PR-URL: nodejs#1092 Reviewed-By: Fedor Indutny <fedor@indutny.com>
Member
|
LGTM |
Member
Author
|
@indutny I pushed another commit to fix a memory leak in the fs.writeSync() error path. Can you PTAL? |
Member
Author
|
Those SYNC_CALL and ASYNC_CALL macros are a special kind of evil. One of the first rules of C macros is that you don't push control flow into them and what do they do? Exactly. |
Member
There was a problem hiding this comment.
So you pas buf here, where does it die?
Member
There was a problem hiding this comment.
Anyway it seems that the buf should be deallocated somewhere.
Member
Author
There was a problem hiding this comment.
It's freed by FSReqWrap's destructor because ownership == MOVE.
Member
|
One comment, otherwise LGTM |
Member
There was a problem hiding this comment.
Oh, I guess it becomes parts of FSReqWrap?
6f9e503 to
528d878
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a bad delete of a pointer that was allocated with placement new.
Casting the pointer was not the right solution because there was at
least one non-placement new constructor call.
This commit rewrites FSReqWrap to be more explicit about ownership of
the auxiliary data and removes a number of egregious const_casts.
The ASYNC_DEST_CALL macro also gets significantly slimmed down.
R=@indutny
Is there a bug number I should reference in the commit log?
https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/257/