Language: Java
Label: vulnerable
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 static void writeResource(LPDataOutput output, IResource resource) throws IOException {
		if (resource == null) {
			output.writeInt(-1);
			return;
		}
		ResourceNetwork[] values = ResourceNetwork.values();
		for (ResourceNetwork value : values) {
			if (value.clazz.isAssignableFrom(resource.getClass())) {
				output.writeInt(value.ordinal());
				resource.writeData(output);
				return;
			}
		}
		throw new UnsupportedOperationException(resource.getClass().toString());
	}