mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
InventoryManager: verify slot existence in locateWindowAndSlot()
previously, this would happily return invalid slot IDs, potentially leading to a crash.
This commit is contained in:
parent
1d10107024
commit
5a54d09869
@ -205,11 +205,13 @@ class InventoryManager{
|
|||||||
if($entry === null){
|
if($entry === null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
$inventory = $entry->getInventory();
|
||||||
$coreSlotId = $entry->mapNetToCore($netSlotId);
|
$coreSlotId = $entry->mapNetToCore($netSlotId);
|
||||||
return $coreSlotId !== null ? [$entry->getInventory(), $coreSlotId] : null;
|
return $coreSlotId !== null && $inventory->slotExists($coreSlotId) ? [$inventory, $coreSlotId] : null;
|
||||||
}
|
}
|
||||||
if(isset($this->networkIdToInventoryMap[$windowId])){
|
$inventory = $this->networkIdToInventoryMap[$windowId] ?? null;
|
||||||
return [$this->networkIdToInventoryMap[$windowId], $netSlotId];
|
if($inventory !== null && $inventory->slotExists($netSlotId)){
|
||||||
|
return [$inventory, $netSlotId];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user