Fix opml import crash

The opml parsing code handles cases where there are extra levels in the xml file
by copying the child to the main container. This corrupts the source instance
during the copy, which leads to corruption in the destination, and ultimately a
crash when it is later used.

To fix, do the copy in two steps, copying the child container to a temporary
location before copying to the destination.
This commit is contained in:
Jim Broadus 2020-10-16 22:00:35 -07:00 committed by John Maguire
parent 4e3e9c8d14
commit fc4cb6fc7a
1 changed files with 8 additions and 2 deletions

View File

@ -279,8 +279,14 @@ bool PodcastParser::ParseOpml(QXmlStreamReader* reader,
ParseOutline(reader, ret);
// OPML files sometimes consist of a single top level container.
while (ret->feeds.count() == 0 && ret->containers.count() == 1) {
*ret = ret->containers[0];
OpmlContainer* top = ret;
while (top->feeds.count() == 0 && top->containers.count() == 1) {
top = &top->containers[0];
}
if (top != ret) {
// Copy the sub-container to a temporary location first.
OpmlContainer tmp = *top;
*ret = tmp;
}
return true;