Skip to content

Commit

Permalink
prevent assigning nullptr to string object
Browse files Browse the repository at this point in the history
  • Loading branch information
mgieseki committed Jul 23, 2024
1 parent f5941ea commit 094467c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/optimizer/ClipPathReassigner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ void ClipPathReassigner::execute (XMLElement *defs, XMLElement *context) {
ids.insert(id);
}
for (auto it = descendants.begin(); it != descendants.end();) {
string id = extract_id_from_url((*it)->getAttributeValue("clip-path"));
if (ids.find(id) == ids.end())
++it;
else {
(*it)->addAttribute("clip-path", string("url(#") + (*ids.begin()) + ")");
it = descendants.erase(it); // no need to process this element again
if (const char *clipPathRef = (*it)->getAttributeValue("clip-path")) {
if (ids.find(extract_id_from_url(clipPathRef)) == ids.end())
++it;
else {
(*it)->addAttribute("clip-path", string("url(#") + (*ids.begin()) + ")");
it = descendants.erase(it); // no need to process this element again
}
}
}
}
Expand Down

0 comments on commit 094467c

Please sign in to comment.