svg: prevent runtime error

runtime error: applying non-zero offset 1 to null pointer
Observed for Bespoke-leather-belt-2016012857.svg
This commit is contained in:
Mira Grudzinska 2024-10-24 10:57:36 +07:00 committed by Hermet Park
parent cebc29c5ff
commit 35bc063edd

View file

@ -492,13 +492,13 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
key[0] = '\0';
val[0] = '\0';
if (next == nullptr && sep != nullptr) {
if (sep != nullptr && next == nullptr) {
memcpy(key, buf, sep - buf);
key[sep - buf] = '\0';
memcpy(val, sep + 1, end - sep - 1);
val[end - sep - 1] = '\0';
} else if (sep < next && sep != nullptr) {
} else if (sep != nullptr && sep < next) {
memcpy(key, buf, sep - buf);
key[sep - buf] = '\0';
@ -522,8 +522,9 @@ bool simpleXmlParseW3CAttribute(const char* buf, unsigned bufLength, simpleXMLAt
}
}
if (!next) break;
buf = next + 1;
} while (next != nullptr);
} while (true);
return true;
}