Skip to content

undefined behavior in grow() #9

Description

@phillipwood

I saw the link to this project on hacker news, it looks interesting. One thing I noticed was that in grow() it has

// TYPE1 -> TYPE4
RELOC(4)
memcpy (newdata, DATA(newhead, TYPE1), dims.len+1); 

the result of memcpy() is undefined when the source and destination overlap, this should use memmove() instead. One a related note the code to grow a string seems to be duplicated in a different form in resize(), perhaps that could call grow() instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions