Fix memory leaks in Assembler::CreateExportDirectory#50431
Merged
1 commit merged intodotnet:mainfrom Apr 16, 2021
Merged
Conversation
Use smart pointers to avoid having to manually deallocate memory. - szOutputFileName was never being deallocated - `pAlias` and `exportDirData` were only being deallocated on the success path and not on any of the error paths.
omajid
commented
Mar 30, 2021
|
|
||
| // Export address table | ||
| DWORD* pEAT = (DWORD*)exportDirData; | ||
| DWORD* pEAT = (DWORD*)(BYTE*)exportDirData; |
Member
Author
There was a problem hiding this comment.
This isn't a change in this PR, but a DWORD (unsigned int on my machine) might have a different alignment than a BYTE (char on my machine). Could this fail?
Member
There was a problem hiding this comment.
malloc on Linux returns 8 byte aligned memory for 32 bit systems and 16 byte aligned ones on 64 bit systems. See https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html. I assume new would behave the same way.
|
Hello @janvorli! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
This pull request was closed.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Use smart pointers to avoid having to manually deallocate memory.
szOutputFileName was never being deallocated
pAliasandexportDirDatawere only being deallocated on the success path and not on any of the error paths.