Skip to content

Commit

Permalink
Fix: segmentation fault with HealthCheck=None and forced repair (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnzbk authored Dec 23, 2024
1 parent 9f755bf commit e5cbe71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions daemon/postprocess/ParChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,13 @@ void ParChecker::SignalDone(std::string fileName, int available, int total)
bool fileExists = true;
for (Par2::Par2RepairerSourceFile* sourcefile : GetRepairer()->sourcefiles)
{
if (!sourcefile)
{
continue;
}

std::string targetFileName = sourcefile->TargetFileName();
if (sourcefile && !strcmp(fileName.c_str(), FileSystem::BaseFileName(targetFileName.c_str())) &&
!sourcefile->GetTargetExists())
if (!sourcefile->GetTargetExists() && fileName == FileSystem::BaseFileName(targetFileName.c_str()))
{
fileExists = false;
break;
Expand Down Expand Up @@ -1124,6 +1128,11 @@ void ParChecker::SaveSourceList()

for (Par2::Par2RepairerSourceFile* sourcefile : GetRepairer()->sourcefiles)
{
if (!sourcefile)
{
continue;
}

std::vector<Par2::DataBlock>::iterator it2 = sourcefile->SourceBlocks();
for (int i = 0; i < (int)sourcefile->BlockCount(); i++, it2++)
{
Expand All @@ -1144,14 +1153,17 @@ void ParChecker::DeleteLeftovers()
// corresponding target-files. If not - the source file was replaced. In this case
// the DiskFile-object points to the renamed bak-file, which we can delete.

for (void* sf : m_sourceFiles)
for (Par2::DiskFile* sourceFile : m_sourceFiles)
{
Par2::DiskFile* sourceFile = (Par2::DiskFile*)sf;
if (!sourceFile)
{
continue;
}

bool found = false;
for (Par2::Par2RepairerSourceFile* sourcefile : GetRepairer()->sourcefiles)
{
if (sourcefile->GetTargetFile() == sourceFile)
if (sourcefile && sourcefile->GetTargetFile() == sourceFile)
{
found = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion daemon/postprocess/ParChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class ParChecker
};

typedef std::deque<std::string> FileList;
typedef std::deque<void*> SourceList;
typedef std::deque<Par2::DiskFile*> SourceList;
typedef std::vector<bool> ValidBlocks;

bool m_queuedParFilesChanged;
Expand Down

0 comments on commit e5cbe71

Please sign in to comment.