tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.45k stars 406 forks source link

Segmentation fault on `manifest.cpp` in `canonicalize` method #683

Open luco5826 opened 1 year ago

luco5826 commented 1 year ago

Hi! I've stumbled upon a segmentation fault while loading an XLSX exported with Libreoffice.

Unluckily the document is under NDA but I've found the culprit and it is this instruction

In particular, when relative contains a relative path that starts with an .., the second if tries to pop_back() an empty vector and crashes

This snippet fixes the issue but I'm not sure it is functionally the same as before

if (component == "..")
{
    if (absolute_parts.size() > 0)
    {
         absolute_parts.pop_back();
    }

     continue;
}
musshorn commented 1 year ago

I've plugged this code in and it seems to pass all the tests, feel free to raise a PR if you want.