-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix two bugs with unsafe memory access (#253)
* Add unit tests to demonstrate two unsafe bugs * Fix bug in embedded pointer nil-check in encoder/decoder Both encoder and decoder examine the wrong variable when checking for nil embedded pointer in a struct. * Fix wrong-size allocation of embedded pointer structs in decoder When a nil embedded pointer is encountered in the decoder, it attempts to allocate a fresh struct on the heap and assign its address into the embedded pointer, so nested decoding can continue. However, it mistakenly allocates a pointer-sized memory block, rather than struct-sized.
- Loading branch information
Showing
4 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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