Skip to content

Fix assign nil slice value #276

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

Merged
merged 1 commit into from
Aug 13, 2021
Merged

Fix assign nil slice value #276

merged 1 commit into from
Aug 13, 2021

Conversation

goccy
Copy link
Owner

@goccy goccy commented Aug 13, 2021

fix #275 ( also fix #268 )

If you decode using the same variable multiple times, the pointer from the previous decoding remains.
At this time, for example, the slice size is 32bytes in a 64-bit environment, so if library initialize only the start address with nil, the latter 24 bytes will remain with invalid values. To avoid this, I tried to initialize all fields by typedmemmove .

@codecov-commenter
Copy link

Codecov Report

Merging #276 (bf35de8) into master (14f03c1) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #276      +/-   ##
==========================================
+ Coverage   81.33%   81.34%   +0.01%     
==========================================
  Files          47       47              
  Lines       15516    15516              
==========================================
+ Hits        12620    12622       +2     
+ Misses       2336     2335       -1     
+ Partials      560      559       -1     

@goccy goccy merged commit d7cdabe into master Aug 13, 2021
@goccy goccy deleted the feature/fix-nil-slice branch August 13, 2021 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random seg fault on Unmarshal nil exeption at internal/decoder/slice.go:65
2 participants