#fixed code
                              @Test
  public void testMaxHistoryFileRows() {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
    try (BufferedWriter bw =
             new BufferedWriter(
                 new OutputStreamWriter(
                     new FileOutputStream(tmpHistoryFile),
                     StandardCharsets.UTF_8))) {
      bw.write("1536743099591:SELECT \\n CURRENT_TIMESTAMP \\n as \\n c1;\n"
          + "1536743104551:SELECT \\n 'asd' as \"sdf\", 4 \\n \\n as \\n c2;\\n\n"
          + "1536743104551:SELECT \\n 'asd' \\n as \\n c2;\\n\n"
          + "1536743104551:!/ 2\n"
          + "1536743104551:SELECT \\n 2123 \\n as \\n c2 from dual;\\n\n"
          + "1536743107526:!history\n"
          + "1536743115431:SELECT \\n 2 \\n as \\n c2;\n"
          + "1536743115431:SELECT \\n '213' \\n as \\n c1;\n"
          + "1536743115431:!/ 8\n");
      bw.flush();
      bw.close();

      SqlLine.Status status = begin(sqlLine, os, true,
          "--historyfile=" + tmpHistoryFile.getAbsolutePath(),
          "-e", "!set maxwidth 80");
      assertThat(status, equalTo(SqlLine.Status.OK));
      DispatchCallback dc = new DispatchCallback();

      final int maxLines = 3;
      sqlLine.runCommands(dc, "!set maxHistoryFileRows " + maxLines);
      os.reset();
      sqlLine.runCommands(dc, "!history");
      assertEquals(maxLines + 1,
          os.toString("UTF8").split("\\s+\\d{2}:\\d{2}:\\d{2}\\s+").length);
      os.reset();
    } catch (Exception e) {
      // fail
      throw new RuntimeException(e);
    }
  }
#vulnerable code 
                              @Test
  public void testMaxHistoryFileRows() {
    final SqlLine beeLine = new SqlLine();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    final File tmpHistoryFile = createTempFile("tmpHistory", "temp");
    try (BufferedWriter bw =
             new BufferedWriter(
                 new OutputStreamWriter(
                     new FileOutputStream(tmpHistoryFile),
                     StandardCharsets.UTF_8))) {
      bw.write("1536743099591:SELECT \\n CURRENT_TIMESTAMP \\n as \\n c1;\n"
          + "1536743104551:SELECT \\n 'asd' as \"sdf\", 4 \\n \\n as \\n c2;\\n\n"
          + "1536743104551:SELECT \\n 'asd' \\n as \\n c2;\\n\n"
          + "1536743104551:!/ 2\n"
          + "1536743104551:SELECT \\n 2123 \\n as \\n c2 from dual;\\n\n"
          + "1536743107526:!history\n"
          + "1536743115431:SELECT \\n 2 \\n as \\n c2;\n"
          + "1536743115431:SELECT \\n '213' \\n as \\n c1;\n"
          + "1536743115431:!/ 8\n");
      bw.flush();
      bw.close();

      SqlLine.Status status = begin(beeLine, os, true,
          "--historyfile=" + tmpHistoryFile.getAbsolutePath(),
          "-e", "!set maxwidth 80");
      assertThat(status, equalTo(SqlLine.Status.OK));
      DispatchCallback dc = new DispatchCallback();

      final int maxLines = 3;
      beeLine.runCommands(dc, "!set maxHistoryFileRows " + maxLines);
      os.reset();
      beeLine.runCommands(dc, "!history");
      assertEquals(maxLines + 1,
          os.toString("UTF8").split("\\s+\\d{2}:\\d{2}:\\d{2}\\s+").length);
      os.reset();
    } catch (Exception e) {
      // fail
      throw new RuntimeException(e);
    }
  } 
                            #location 32 
                            #vulnerability type RESOURCE_LEAK