#fixed code
                              private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
    Session session = Session.getDefaultInstance(emailSessionProperties);
    Message message = new MimeMessage(session);
    try {
      message.setSubject("Hank: " + name);
      for (String emailTarget : emailTargets) {
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailTarget));
      }
      message.setText(body);
      Transport.send(message);
    } catch (MessagingException e) {
      throw new RuntimeException("Failed to send notification email.", e);
    }
  }
#vulnerable code 
                              private void sendEmails(Set<String> emailTargets, String body) throws IOException, InterruptedException {
    for (String emailTarget : emailTargets) {
      String[] command = {"/bin/mail", "-s", "Hank: " + name, emailTarget};
      Process process = Runtime.getRuntime().exec(command);
      OutputStreamWriter writer = new OutputStreamWriter(process.getOutputStream());
      writer.write(body);
      writer.close();
      process.getOutputStream().close();
      process.waitFor();
    }
  } 
                            #location 9 
                            #vulnerability type RESOURCE_LEAK