PlistCpp icon indicating copy to clipboard operation
PlistCpp copied to clipboard

crash when string size is zero

Open skkiran-pro opened this issue 12 years ago • 1 comments

very useful library.

i got a crash when one of the strings in a plist had empty string. to fix it had to change parseBinaryString to following:

inline std::string Plist::parseBinaryString(const PlistHelperData& d, int headerPosition)
{
    unsigned char headerByte = d._objectTable[headerPosition];
    int charStartPosition;
    int32_t charCount = getCount(d, headerPosition, headerByte, charStartPosition);
    charStartPosition += headerPosition;

        std::string buffer;
        if (charCount > 0)
        {
      std::vector<unsigned char> characterBytes = getRange(d._objectTable, charStartPosition, charCount);
      buffer = std::string((char*) vecData(characterBytes), characterBytes.size()); 
        }
    return buffer;
}

skkiran-pro avatar Nov 02 '12 15:11 skkiran-pro

Hi, sorry I can't replicate this issue. Not sure if it has been inadvertently fixed. I added an empty string test for both binary and xml and it passes. Do you have a plist to replicate?

animetrics avatar Mar 18 '14 18:03 animetrics