summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-09-25 15:23:58 -0400
committerJosh Ferrell <josh@vector35.com>2024-09-25 17:11:36 -0400
commit3e5ecf7a6d7ed6996eb62a8cfb4849e7556cec99 (patch)
tree9144b77536503a338cb6dafdea1bb13a60402396
parent6f19d94cf12146f381caab59618d8ba8a4a992b1 (diff)
Fix bad any cast on mac
-rw-r--r--binaryninjacore.h1
-rw-r--r--collaboration.cpp19
2 files changed, 8 insertions, 12 deletions
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 2d3fbca3..cb5835c3 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -7545,6 +7545,7 @@ extern "C"
BINARYNINJACOREAPI BNSnapshot* BNAnalysisMergeConflictGetFirstSnapshot(BNAnalysisMergeConflict* conflict);
BINARYNINJACOREAPI BNSnapshot* BNAnalysisMergeConflictGetSecondSnapshot(BNAnalysisMergeConflict* conflict);
BINARYNINJACOREAPI char* BNAnalysisMergeConflictGetPathItemString(BNAnalysisMergeConflict* conflict, const char* path);
+ BINARYNINJACOREAPI char* BNAnalysisMergeConflictGetPathItemSerialized(BNAnalysisMergeConflict* conflict, const char* path);
BINARYNINJACOREAPI void* BNAnalysisMergeConflictGetPathItem(BNAnalysisMergeConflict* conflict, const char* path);
BINARYNINJACOREAPI bool BNAnalysisMergeConflictSuccess(BNAnalysisMergeConflict* conflict, const char* value);
diff --git a/collaboration.cpp b/collaboration.cpp
index f3bb242e..f154865a 100644
--- a/collaboration.cpp
+++ b/collaboration.cpp
@@ -2221,18 +2221,13 @@ std::string AnalysisMergeConflict::GetPathItem<std::string>(const std::string& p
template <>
nlohmann::json AnalysisMergeConflict::GetPathItem<nlohmann::json>(const std::string& path)
{
- std::any anyVal = GetPathItem<std::any>(path);
- try
- {
- return std::any_cast<nlohmann::json>(anyVal);
- }
- catch (const std::exception& e)
- {
- throw SyncException(fmt::format(
- "Failed to cast merge conflict path item \"{}\" from \"{}\" to \"{}\": {}",
- path, anyVal.type().name(), typeid(nlohmann::json).name(), e.what()
- ));
- }
+ char* val = BNAnalysisMergeConflictGetPathItemSerialized(m_object, path.c_str());
+ if (val == nullptr)
+ throw SyncException(fmt::format("Failed to find merge conflict path item \"{}\"", path));
+
+ std::string strVal = val;
+ BNFreeString(val);
+ return nlohmann::json::parse(strVal);
}