#vulnerable code 
                             public static ExtensionObject binaryEncode(Structure encodeable, IEncodeableSerializer serializer, EncoderContext ctx)
	throws EncodingException {
		ctx.setEncodeableSerializer(serializer);
		
		int limit = ctx.getMaxByteStringLength();
		if(limit == 0) {
			limit = ctx.getMaxMessageSize();
		}
		if(limit == 0) {
			limit = Integer.MAX_VALUE;
		}
		LimitedByteArrayOutputStream stream = LimitedByteArrayOutputStream.withSizeLimit(limit);
		BinaryEncoder enc = new BinaryEncoder(stream);
		enc.setEncoderContext(ctx);
		enc.putEncodeable(null, encodeable);
		
		return new ExtensionObject(encodeable.getBinaryEncodeId(), stream.toByteArray());
	} 
                            #location 17 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             public static ExtensionObject binaryEncode(Structure encodeable, IEncodeableSerializer serializer, EncoderContext ctx)
	throws EncodingException {
		ctx.setEncodeableSerializer(serializer);
		
		int limit = ctx.getMaxByteStringLength();
		if(limit == 0) {
			limit = ctx.getMaxMessageSize();
		}
		if(limit == 0) {
			limit = Integer.MAX_VALUE;
		}
		LimitedByteArrayOutputStream buf = LimitedByteArrayOutputStream.withSizeLimit(limit);
		BinaryEncoder enc = new BinaryEncoder(buf);
		enc.setEncoderContext(ctx);
		enc.putEncodeable(null, encodeable);
		
		return new ExtensionObject(encodeable.getBinaryEncodeId(), buf.toByteArray());
	}