Skip to content

Commit 094467c

Browse files
committed
prevent assigning nullptr to string object
1 parent f5941ea commit 094467c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/optimizer/ClipPathReassigner.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ void ClipPathReassigner::execute (XMLElement *defs, XMLElement *context) {
8181
ids.insert(id);
8282
}
8383
for (auto it = descendants.begin(); it != descendants.end();) {
84-
string id = extract_id_from_url((*it)->getAttributeValue("clip-path"));
85-
if (ids.find(id) == ids.end())
86-
++it;
87-
else {
88-
(*it)->addAttribute("clip-path", string("url(#") + (*ids.begin()) + ")");
89-
it = descendants.erase(it); // no need to process this element again
84+
if (const char *clipPathRef = (*it)->getAttributeValue("clip-path")) {
85+
if (ids.find(extract_id_from_url(clipPathRef)) == ids.end())
86+
++it;
87+
else {
88+
(*it)->addAttribute("clip-path", string("url(#") + (*ids.begin()) + ")");
89+
it = descendants.erase(it); // no need to process this element again
90+
}
9091
}
9192
}
9293
}

0 commit comments

Comments
 (0)