From d1722c0b34f313590f1f5a1274985433a58a7a5f Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 11 Apr 2025 15:54:10 -0400 Subject: Fix BNVersionInfo leaking --- binaryninjaapi.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 680b9592..e2275fdc 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1156,6 +1156,28 @@ namespace BinaryNinja { @addtogroup coreapi @{ */ + struct VersionInfo + { + uint32_t major {}; + uint32_t minor {}; + uint32_t build {}; + std::string channel; + + VersionInfo() = default; + + bool operator<(const VersionInfo &other) const + { + char* smallerChan = BNAllocString(channel.c_str()); + char* largerChan = BNAllocString(other.channel.c_str()); + BNVersionInfo smaller = { major, minor, build, smallerChan }; + BNVersionInfo larger = { other.major, other.minor, other.build, largerChan }; + bool result = BNVersionLessThan(smaller, larger); + BNFreeString(smallerChan); + BNFreeString(largerChan); + return result; + } + }; + std::string EscapeString(const std::string& s); std::string UnescapeString(const std::string& s); @@ -1192,6 +1214,8 @@ namespace BinaryNinja { std::string& output, std::string& errors, bool stdoutIsText = false, bool stderrIsText = true); std::string GetVersionString(); + VersionInfo GetVersionInfo(); + VersionInfo ParseVersionString(const std::string& version); std::string GetLicensedUserEmail(); std::string GetProduct(); std::string GetProductType(); @@ -16836,8 +16860,8 @@ namespace BinaryNinja { std::string GetCommit() const; std::string GetRepository() const; std::string GetProjectData(); - BNVersionInfo GetMinimumVersionInfo() const; - BNVersionInfo GetMaximumVersionInfo() const; + VersionInfo GetMinimumVersionInfo() const; + VersionInfo GetMaximumVersionInfo() const; uint64_t GetLastUpdate(); bool IsViewOnly() const; bool IsBeingDeleted() const; -- cgit v1.3.1