From 7404d03ea9a59ace6da112a98a0a1c21b2ad3e53 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:58:24 +0200 Subject: [PATCH] fixed potential undefined behaviour when using escape rope (#4705) --- src/item_use.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/item_use.c b/src/item_use.c index 0d3efe6ff90b..502612a18407 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -1041,14 +1041,10 @@ static void ItemUseOnFieldCB_EscapeRope(u8 taskId) { Overworld_ResetStateAfterDigEscRope(); if (I_KEY_ESCAPE_ROPE < GEN_8) - { - RemoveUsedItem(); - } - else - { - CopyItemName(gSpecialVar_ItemId, gStringVar2); - StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); - } + RemoveBagItem(gSpecialVar_ItemId, 1); + + CopyItemName(gSpecialVar_ItemId, gStringVar2); + StringExpandPlaceholders(gStringVar4, gText_PlayerUsedVar2); gTasks[taskId].data[0] = 0; DisplayItemMessageOnField(taskId, gStringVar4, Task_UseDigEscapeRopeOnField); }