parse_named_tag: Handle read_string error#27
Open
neuschaefer wants to merge 1 commit intochmod222:masterfrom
Open
parse_named_tag: Handle read_string error#27neuschaefer wants to merge 1 commit intochmod222:masterfrom
neuschaefer wants to merge 1 commit intochmod222:masterfrom
Conversation
When read_string fails in parse_named_tag, handle the error. This avoids
a memory leak.
$ gcc -fsanitize=leak -O2 -g nbt*.c buffer.c afl_check.c -lz -o afl_check
$ echo H4sIAAFPPWQCA+3cMQ0AMAwDwTlszLJjKTckKkXK3fAYPLlOKk1ERERERLYGAAAAAAAAAAAAAAAAAAAAAAAAAL5xewcA2BgAAAAAwDA3yQPu9ekG1ncAAA== | base64 -d | gunzip | ./afl_check
=================================================================
==1071335==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f6df2213545 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
chmod222#1 0x563703627739 in read_list /home/jn/dev/misc/cNBT/nbt_parsing.c:294
chmod222#2 0x563703627739 in parse_unnamed_tag /home/jn/dev/misc/cNBT/nbt_parsing.c:431
chmod222#3 0x7ffd360b3d2f ([stack]+0x90d2f)
Indirect leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x7f6df2213545 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
chmod222#1 0x56370362774f in read_list /home/jn/dev/misc/cNBT/nbt_parsing.c:298
chmod222#2 0x56370362774f in parse_unnamed_tag /home/jn/dev/misc/cNBT/nbt_parsing.c:431
chmod222#3 0x7ffd360b3d2f ([stack]+0x90d2f)
SUMMARY: LeakSanitizer: 56 byte(s) leaked in 2 allocation(s).
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.
When read_string fails in parse_named_tag, handle the error. This avoids a memory leak.