Skip to content

Commit

Permalink
Fix strdup for LibXML: undefined behavior
Browse files Browse the repository at this point in the history
The last argument of xmlGcMemSetup is a GC-aware implementation of strdup. It should return a valid C-string with the null-character.
  • Loading branch information
lbguilherme authored and asterite committed Jan 14, 2018
1 parent c7cc787 commit b4fed51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/xml/libxml2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ LibXML.xmlGcMemSetup(
->GC.malloc(LibC::SizeT),
->GC.realloc(Void*, LibC::SizeT),
->(str) {
len = LibC.strlen(str)
len = LibC.strlen(str) + 1
copy = Pointer(UInt8).malloc(len)
copy.copy_from(str, len)
copy
Expand Down

0 comments on commit b4fed51

Please sign in to comment.