#vulnerable code 
                             @Test
	public void labels() throws Exception {
		VCard vcard = new VCard();

		//address with label
		AddressType adr = new AddressType();
		adr.setStreetAddress("123 Main St.");
		adr.setLocality("Austin");
		adr.setRegion("TX");
		adr.setPostalCode("12345");
		adr.setLabel("123 Main St.\r\nAustin, TX 12345");
		adr.addType(AddressTypeParameter.HOME);
		vcard.addAddress(adr);

		//address without label
		adr = new AddressType();
		adr.setStreetAddress("222 Broadway");
		adr.setLocality("New York");
		adr.setRegion("NY");
		adr.setPostalCode("99999");
		adr.addType(AddressTypeParameter.WORK);
		vcard.addAddress(adr);

		//orphaned label
		LabelType label = new LabelType("22 Spruce Ln.\r\nChicago, IL 11111");
		label.addType(AddressTypeParameter.PARCEL);
		vcard.addOrphanedLabel(label);

		//3.0
		//LABEL types should be used
		StringWriter sw = new StringWriter();
		VCardWriter vcw = new VCardWriter(sw, VCardVersion.V3_0, null);
		vcw.setAddProdId(false);
		vcw.write(vcard);
		String actual = sw.toString();

		StringBuilder sb = new StringBuilder();
		sb.append("BEGIN:VCARD\r\n");
		sb.append("VERSION:3.0\r\n");
		sb.append("ADR;TYPE=home:;;123 Main St.;Austin;TX;12345;\r\n");
		sb.append("LABEL;TYPE=home:123 Main St.\\nAustin\\, TX 12345\r\n");
		sb.append("ADR;TYPE=work:;;222 Broadway;New York;NY;99999;\r\n");
		sb.append("LABEL;TYPE=parcel:22 Spruce Ln.\\nChicago\\, IL 11111\r\n");
		sb.append("END:VCARD\r\n");
		String expected = sb.toString();

		assertEquals(expected, actual);

		//4.0
		//LABEL parameters should be used
		sw = new StringWriter();
		vcw = new VCardWriter(sw, VCardVersion.V4_0, null);
		vcw.setAddProdId(false);
		vcw.write(vcard);
		actual = sw.toString();

		sb = new StringBuilder();
		sb.append("BEGIN:VCARD\r\n");
		sb.append("VERSION:4.0\r\n");
		sb.append("ADR;LABEL=\"123 Main St.\\nAustin, TX 12345\";TYPE=home:;;123 Main St.;Austin;TX;12345;\r\n");
		sb.append("ADR;TYPE=work:;;222 Broadway;New York;NY;99999;\r\n");
		sb.append("END:VCARD\r\n");
		expected = sb.toString();

		assertEquals(expected, actual);
	} 
                            #location 34 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             @Test
	public void labels() throws Exception {
		VCard vcard = new VCard();

		//address with label
		AddressType adr = new AddressType();
		adr.setStreetAddress("123 Main St.");
		adr.setLocality("Austin");
		adr.setRegion("TX");
		adr.setPostalCode("12345");
		adr.setLabel("123 Main St.\r\nAustin, TX 12345");
		adr.addType(AddressTypeParameter.HOME);
		vcard.addAddress(adr);

		//address without label
		adr = new AddressType();
		adr.setStreetAddress("222 Broadway");
		adr.setLocality("New York");
		adr.setRegion("NY");
		adr.setPostalCode("99999");
		adr.addType(AddressTypeParameter.WORK);
		vcard.addAddress(adr);

		//orphaned label
		LabelType label = new LabelType("22 Spruce Ln.\r\nChicago, IL 11111");
		label.addType(AddressTypeParameter.PARCEL);
		vcard.addOrphanedLabel(label);

		//3.0
		//LABEL types should be used
		StringWriter sw = new StringWriter();
		VCardWriter vcw = new VCardWriter(sw, VCardVersion.V3_0, null, "\r\n");
		vcw.setAddProdId(false);
		vcw.write(vcard);
		String actual = sw.toString();

		StringBuilder sb = new StringBuilder();
		sb.append("BEGIN:VCARD\r\n");
		sb.append("VERSION:3.0\r\n");
		sb.append("ADR;TYPE=home:;;123 Main St.;Austin;TX;12345;\r\n");
		sb.append("LABEL;TYPE=home:123 Main St.\\nAustin\\, TX 12345\r\n");
		sb.append("ADR;TYPE=work:;;222 Broadway;New York;NY;99999;\r\n");
		sb.append("LABEL;TYPE=parcel:22 Spruce Ln.\\nChicago\\, IL 11111\r\n");
		sb.append("END:VCARD\r\n");
		String expected = sb.toString();

		assertEquals(expected, actual);

		//4.0
		//LABEL parameters should be used
		sw = new StringWriter();
		vcw = new VCardWriter(sw, VCardVersion.V4_0, null, "\r\n");
		vcw.setAddProdId(false);
		vcw.write(vcard);
		actual = sw.toString();

		sb = new StringBuilder();
		sb.append("BEGIN:VCARD\r\n");
		sb.append("VERSION:4.0\r\n");
		sb.append("ADR;LABEL=\"123 Main St.\\nAustin, TX 12345\";TYPE=home:;;123 Main St.;Austin;TX;12345;\r\n");
		sb.append("ADR;TYPE=work:;;222 Broadway;New York;NY;99999;\r\n");
		sb.append("END:VCARD\r\n");
		expected = sb.toString();

		assertEquals(expected, actual);
	}