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 writeData(LPDataOutput output) {
		super.writeData(output);

		output.writeInt(content.length);

		for (int i = 0; i < content.length; i++) {
			final ItemStack itemstack = content[i];

			if (itemstack != null) {
				output.writeByte(i);
				output.writeInt(Item.getIdFromItem(itemstack.getItem()));
				output.writeInt(itemstack.stackSize);
				output.writeInt(itemstack.getItemDamage());
				output.writeNBTTagCompound(itemstack.getTagCompound());
			}
		}
		output.writeByte(-1); // mark packet end
	}