Skip to content

Commit 664bdcd

Browse files
committed
[SharedCache] Fix project folder comparison crash
Fixes #6629
1 parent bf64859 commit 664bdcd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

view/sharedcache/core/SharedCacheBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ size_t SharedCacheBuilder::AddProjectFolder(Ref<ProjectFolder> folder)
8383
const auto currentFileName = file.GetName();
8484

8585
// Skip files not in the folder.
86-
if (const auto currentFolder = file.GetFolder(); folder)
87-
if (currentFolder->GetId() != folder->GetId())
88-
return false;
86+
if (!IsSameFolder(file.GetFolder(), folder))
87+
return false;
8988

9089
// Ok, we are now _sure_ that this file _might_ be a part of the cache, lets try and process it!
9190
return AddFile(currentFilePath, currentFileName, CacheEntryType::Secondary);

view/sharedcache/core/Utility.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,12 @@ std::string BaseFileName(const std::string& path)
136136
return path.substr(lastSlashPos + 1);
137137
return path;
138138
}
139+
140+
bool IsSameFolder(Ref<ProjectFolder> a, Ref<ProjectFolder> b)
141+
{
142+
if (!a && !b)
143+
return true;
144+
if (a && b)
145+
return a->GetId() == b->GetId();
146+
return false;
147+
}

view/sharedcache/core/Utility.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void ApplySymbol(BinaryNinja::Ref<BinaryNinja::BinaryView> view, BinaryNinja::Re
4040
// /blah/foo/bar/libObjCThing.dylib -> libObjCThing.dylib
4141
std::string BaseFileName(const std::string& path);
4242

43+
bool IsSameFolder(BinaryNinja::Ref<BinaryNinja::ProjectFolder> a, BinaryNinja::Ref<BinaryNinja::ProjectFolder> b);
44+
4345
// Represents a range of addresses [start, end).
4446
// Note that `end` is not included within the range.
4547
struct AddressRange

0 commit comments

Comments
 (0)