#vulnerable code 
                              public View handle(HttpServletRequest req) throws IOSAutomationException {
    String path = req.getPathInfo();
    String pattern = "/resources/";
    int end = path.indexOf(pattern) + pattern.length();

    String resource = path.substring(end);

    InputStream is = null;
    if (resource.endsWith("lastScreen.png")) {
      is = getModel().getLastScreenshotInputStream();
    } else {
      is = IDEServlet.class.getResourceAsStream("/" + resource);
    }
    String mime = getMimeType(resource);
    if (is == null) {
      throw new IOSAutomationException("error getting resource " + req.getPathInfo()
          + req.getQueryString());
    }
    return new ResourceView(is, mime);
  } 
                            #location 19 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              public View handle(HttpServletRequest req) throws IOSAutomationException {
    String path = req.getPathInfo();
    String pattern = "/resources/";
    int end = path.indexOf(pattern) + pattern.length();

    String resource = path.substring(end);

    InputStream is = null;
    if (resource.endsWith("lastScreen.png")) {
      //is = getModel().getLastScreenshotInputStream();
    } else {
      is = IDEServlet.class.getResourceAsStream("/" + resource);
    }
    String mime = getMimeType(resource);
    if (is == null) {
      throw new IOSAutomationException("error getting resource " + req.getPathInfo()
          + req.getQueryString());
    }
    return new ResourceView(is, mime);
  }