aclements / libelfin

C++11 ELF/DWARF parser
MIT License
314 stars 99 forks source link

fix cursor.cc reading an empty string error when compile without "-o2… #63

Open ryanhuang opened 2 years ago

ryanhuang commented 2 years ago

fix cursor.cc reading an empty string error when compile without "-o2…

void
cursor::string(std::string &out)
{
        size_t size;
        const char *p = this->cstr(&size);
        out.resize(size);
    if (size > 0)
    {
            memmove(&out.front(), p, size);
    }
}

without -o2, "memmove(&out.front(), p, 0) will raise an assert error in gcc8.1.4 centos 8.5(4.18.0-348.2.1.el8_5.x86_64)"