Language: Java
Label: safe
CWE: CWE-502 \u2014 Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.

Code:
	public void InventoryChanged(SimpleInventory inventory) {
		boolean needUpdate = false;
		for(int i=0;i<inv.getSizeInventory() - 1;i++) {
			ItemStack item = inv.getStackInSlot(i);
			if(item != null) {
				needUpdate |= updateModule(i);
			} else if(item == null && upgrades[i] != null) {
				needUpdate |= removeUpgrade(i);
			}
		}
		//update sneaky direction, speed upgrade count and disconnection
		sneakyOrientation = ForgeDirection.UNKNOWN;
		speedUpgradeCount = 0;
		isAdvancedCrafter = false;
		isSatelliteCraftingSatellite = false;
		isSatelliteCraftingCrafter = false;
		disconnectedSides.clear();
		for(int i=0;i<upgrades.length;i++) {
			IPipeUpgrade upgrade = upgrades[i];
			if(upgrade instanceof SneakyUpgrade && sneakyOrientation == ForgeDirection.UNKNOWN) {
				sneakyOrientation = ((SneakyUpgrade) upgrade).getSneakyOrientation();
			} else if(upgrade instanceof SpeedUpgrade) {
				speedUpgradeCount += inv.getStackInSlot(i).stackSize;
			} else if(upgrade instanceof ConnectionUpgrade) {
				disconnectedSides.add(((ConnectionUpgrade)upgrade).getSide());
			} else if(upgrade instanceof SplitCraftingCrafterUpgrade) {
				isSatelliteCraftingCrafter = true;
			} else if(upgrade instanceof SplitCraftingSatelliteUpgrade) {
				isSatelliteCraftingSatellite = true;
			} else if(upgrade instanceof AdvancedSatelliteUpgrade) {
				isAdvancedCrafter = true;
			}
		}
		if(needUpdate) {
			pipe.connectionUpdate();
		}
	}