Qt: Fix potential null deref

This commit is contained in:
Vicki Pfau 2024-01-30 16:09:25 -08:00
parent 530b997d7e
commit 4cdcfe6dd3
1 changed files with 7 additions and 0 deletions

View File

@ -138,7 +138,14 @@ bool extractMatchingFile(VDir* dir, std::function<QString (VDirEntry*)> filter)
continue;
}
VFile* outfile = VFileOpen(target.toUtf8().constData(), O_WRONLY | O_TRUNC | O_CREAT);
if (!outfile) {
return false;
}
VFile* infile = dir->openFile(dir, entry->name(entry), O_RDONLY);
if (!infile) {
outfile->close(outfile);
return false;
}
VFileDevice::copyFile(infile, outfile);
infile->close(infile);
outfile->close(outfile);