Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions reader/document/DjVuModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,10 @@ bool DjVuDocument::save() const
{
qCDebug(appLog) << "Saving document to:" << m_filePath;
QTemporaryDir tempDir;
if (!tempDir.isValid()) {
qCWarning(appLog) << "Failed to create temporary directory:" << tempDir.errorString();
return false;
}

QString tempFilePath = tempDir.path() + "/" + QUuid::createUuid().toString();

Expand Down
6 changes: 6 additions & 0 deletions reader/uiframe/DocSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,12 @@ QString DocSheet::convertedFileDir()
qCDebug(appLog) << "convertedFileDir";
if (m_tempDir == nullptr)
m_tempDir = new QTemporaryDir;
if (!m_tempDir->isValid()) {
qCWarning(appLog) << "Failed to create temporary directory:" << m_tempDir->errorString();
delete m_tempDir;
m_tempDir = nullptr;
return QString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): The new empty-string failure result is not propagated by its callers: openFileAsync() and openFileExec() pass it to the renderer, while saveAsData() and openedFilePath() append filenames to it. This produces paths such as /saveAsTemp.pdf or /temp.pdf, so conversion and save operations still attempt invalid root-level paths instead of failing gracefully.

Triggers: When QTemporaryDir creation fails, such as with an invalid TMPDIR.

Suggested fix: Check the result of convertedFileDir() at each caller and abort before invoking the renderer or constructing a derived path; make openedFilePath() return an empty result when the conversion directory is unavailable.

}

qCDebug(appLog) << "临时目录: " << m_tempDir->path();
return m_tempDir->path();
Expand Down
Loading