Skip to content

Commit

Permalink
fix: [thumbnail] The dde-file-manager crashed while creating thumbnail
Browse files Browse the repository at this point in the history
1.Failed to create a video file thumbnail in the FTP directory by ffmpeg
2.Array out of bounds

Log: fix bug
Bug: https://pms.uniontech.com/bug-view-210633.html
  • Loading branch information
Kakueeen authored and deepin-bot[bot] committed Jul 21, 2023
1 parent d07ad78 commit fa2ef5f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/dfm-base/utils/thumbnail/thumbnailcreators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,17 @@ QImage ThumbnailCreators::videoThumbnailCreatorFfmpeg(const QString &filePath, T
}

const auto &data = ffmpeg.readAllStandardOutput();
if (data.isEmpty())
return img;

QString outputs(data);
if (!img.loadFromData(data)) // filter the outputs outputed by video tool.
outputs = outputs.split(QRegExp("[\n]"), QString::SkipEmptyParts).last();
if (!img.loadFromData(data)) { // filter the outputs outputed by video tool.
QStringList data = outputs.split(QRegExp("[\n]"), QString::SkipEmptyParts);
if (data.isEmpty())
return img;

outputs = data.last();
}

if (!img.loadFromData(outputs.toLocal8Bit().data(), "png"))
qWarning() << "thumbnail: cannot load image from ffmpeg outputs." << filePath;
Expand Down

0 comments on commit fa2ef5f

Please sign in to comment.