From cdbd80c07e5bd6dbc843d47df71c0e0d7104dc11 Mon Sep 17 00:00:00 2001 From: dystopm Date: Wed, 20 Aug 2025 16:45:18 -0400 Subject: [PATCH 1/2] Fix SetHamItemInfo string memory handling --- modules/hamsandwich/DataHandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/hamsandwich/DataHandler.cpp b/modules/hamsandwich/DataHandler.cpp index 9e286a629f..a86b6f76ec 100644 --- a/modules/hamsandwich/DataHandler.cpp +++ b/modules/hamsandwich/DataHandler.cpp @@ -420,7 +420,8 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) break; case ItemInfo_pszAmmo1: - pItem->pszAmmo1 = MF_GetAmxString(amx, params[3], 0, &iLen); + auto str = MF_GetAmxString(amx, params[3], 0, &iLen); + pItem->pszAmmo1 = str ? STRING(ALLOC_STRING(str)) : nullptr; return iLen; case ItemInfo_iMaxAmmo1: @@ -428,7 +429,8 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) break; case ItemInfo_pszAmmo2: - pItem->pszAmmo2 = MF_GetAmxString(amx, params[3], 0, &iLen); + auto str = MF_GetAmxString(amx, params[3], 0, &iLen); + pItem->pszAmmo2 = str ? STRING(ALLOC_STRING(str)) : nullptr; return iLen; case ItemInfo_iMaxAmmo2: @@ -436,7 +438,8 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) break; case ItemInfo_pszName: - pItem->pszName = MF_GetAmxString(amx, params[3], 0, &iLen); + auto str = MF_GetAmxString(amx, params[3], 0, &iLen); + pItem->pszName = str ? STRING(ALLOC_STRING(str)) : nullptr; return iLen; case ItemInfo_iMaxClip: From e754457b5e90bc6477bbcfd5363df7783d7194d2 Mon Sep 17 00:00:00 2001 From: dystopm Date: Wed, 20 Aug 2025 16:53:41 -0400 Subject: [PATCH 2/2] Fix string compilation --- modules/hamsandwich/DataHandler.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/hamsandwich/DataHandler.cpp b/modules/hamsandwich/DataHandler.cpp index a86b6f76ec..044dea049e 100644 --- a/modules/hamsandwich/DataHandler.cpp +++ b/modules/hamsandwich/DataHandler.cpp @@ -408,6 +408,7 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) ItemInfo *pItem = reinterpret_cast(params[1]); cell *ptr = MF_GetAmxAddr(amx, params[3]); int iLen; + char *szString; switch (params[2]) { @@ -420,8 +421,8 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) break; case ItemInfo_pszAmmo1: - auto str = MF_GetAmxString(amx, params[3], 0, &iLen); - pItem->pszAmmo1 = str ? STRING(ALLOC_STRING(str)) : nullptr; + szString = MF_GetAmxString(amx, params[3], 0, &iLen); + pItem->pszAmmo1 = szString ? STRING(ALLOC_STRING(szString)) : nullptr; return iLen; case ItemInfo_iMaxAmmo1: @@ -429,8 +430,8 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) break; case ItemInfo_pszAmmo2: - auto str = MF_GetAmxString(amx, params[3], 0, &iLen); - pItem->pszAmmo2 = str ? STRING(ALLOC_STRING(str)) : nullptr; + szString = MF_GetAmxString(amx, params[3], 0, &iLen); + pItem->pszAmmo2 = szString ? STRING(ALLOC_STRING(szString)) : nullptr; return iLen; case ItemInfo_iMaxAmmo2: @@ -438,8 +439,8 @@ static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params) break; case ItemInfo_pszName: - auto str = MF_GetAmxString(amx, params[3], 0, &iLen); - pItem->pszName = str ? STRING(ALLOC_STRING(str)) : nullptr; + szString = MF_GetAmxString(amx, params[3], 0, &iLen); + pItem->pszName = szString ? STRING(ALLOC_STRING(szString)) : nullptr; return iLen; case ItemInfo_iMaxClip: