From db192d2cde796823c2ac8670df07389767d3e4dd Mon Sep 17 00:00:00 2001 From: jadebenn Date: Mon, 8 Apr 2024 23:50:41 -0500 Subject: [PATCH 1/2] chore: Fix use of uninitialized variable in RemoveItemFromInventory (#1540) --- dGame/dGameMessages/GameMessages.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 3ef9f3b5..74946179 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -4660,7 +4660,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream& inStream, Entity* enti if (!user) return; Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar()); if (!player) return; - + // handle buying normal items auto* vendorComponent = entity->GetComponent(); if (vendorComponent) { @@ -5290,7 +5290,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream& inStream, En bool iLootTypeSourceIsDefault = false; LWOOBJID iLootTypeSource = LWOOBJID_EMPTY; bool iObjIDIsDefault = false; - LWOOBJID iObjID; + LWOOBJID iObjID = LWOOBJID_EMPTY; bool iObjTemplateIsDefault = false; LOT iObjTemplate = LOT_NULL; bool iRequestingObjIDIsDefault = false; From 1ee45639afdd6713e9730b5da7f82b5eba2cd373 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 8 Apr 2024 22:20:25 -0700 Subject: [PATCH 2/2] Update GeneralUtils.h (#1541) --- dCommon/GeneralUtils.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index f59ec71f..35c0b895 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -158,9 +158,7 @@ namespace GeneralUtils { template [[nodiscard]] std::optional TryParse(std::string_view str) { numeric_parse_t result; - if (!str.empty()) { - while (std::isspace(str.front())) str.remove_prefix(1); - } + while (!str.empty() && std::isspace(str.front())) str.remove_prefix(1); const char* const strEnd = str.data() + str.size(); const auto [parseEnd, ec] = std::from_chars(str.data(), strEnd, result); @@ -186,9 +184,7 @@ namespace GeneralUtils { template [[nodiscard]] std::optional TryParse(std::string_view str) noexcept try { - if (!str.empty()) { - while (std::isspace(str.front())) str.remove_prefix(1); - } + while (!str.empty() && std::isspace(str.front())) str.remove_prefix(1); size_t parseNum; const T result = details::_parse(str, parseNum);