output: #fixed code
                               @Test
  	public void escape_newlines() throws Exception {
  		ICalendar ical = new ICalendar();
  
  		VEvent event = new VEvent();
  		event.setSummary("summary\nof event");
  		ical.addEvent(event);
  
  		StringWriter sw = new StringWriter();
  		ICalWriter writer = new ICalWriter(sw);
  		writer.write(ical);
  		writer.close();
  
  		//@formatter:off
  		String expected = 
  		"BEGIN:VCALENDAR\r\n" +
  			"VERSION:2\\.0\r\n" +
  			"PRODID:.*?\r\n" +
  			"BEGIN:VEVENT\r\n" +
  				"UID:.*?\r\n" +
  				"DTSTAMP:.*?\r\n" +
  				"SUMMARY:summary\\\\nof event\r\n" +
  			"END:VEVENT\r\n" +
  		"END:VCALENDAR\r\n";
  		//@formatter:on
  
  		String actual = sw.toString();
  		assertRegex(expected, actual);
  	}
input: #vulnerable code 
                               @Test
  	public void escape_newlines() throws Exception {
  		ICalendar ical = new ICalendar();
  
  		VEvent event = new VEvent();
  		event.setSummary("summary\nof event");
  		ical.addEvent(event);
  
  		StringWriter sw = new StringWriter();
  		ICalWriter writer = new ICalWriter(sw);
  		writer.write(ical);
  		writer.close();
  
  		//@formatter:off
  		String expected = 
  		"BEGIN:VCALENDAR\r\n" +
  			"VERSION:2\\.0\r\n" +
  			"PRODID:.*?\r\n" +
  			"BEGIN:VEVENT\r\n" +
  				"UID:.*?\r\n" +
  				"DTSTAMP:.*?\r\n" +
  				"SUMMARY:summary\\\\nof event\r\n" +
  			"END:VEVENT\r\n" +
  		"END:VCALENDAR\r\n";
  		//@formatter:on
  
  		String actual = sw.toString();
  		assertRegex(expected, actual);
  		assertWarnings(0, writer.getWarnings());
  	} 
                              #location 30 
                              #vulnerability type RESOURCE_LEAK