#vulnerable code 
                                @Test
    public void testMemMapLocation() throws Exception {
        final File f = new File(LOGFILE);
        if (f.exists()) {
            assertTrue(f.delete());
        }
        assertTrue(!f.exists());
        
        final int expectedFileLength = Integers.ceilingNextPowerOfTwo(32000);
        assertEquals(32768, expectedFileLength);
        
        final Logger log = LogManager.getLogger();
        try {
            log.warn("Test log1");
            assertTrue(f.exists());
            assertEquals("initial length", expectedFileLength, f.length());
            
            log.warn("Test log2");
            assertEquals("not grown", expectedFileLength, f.length());
        } finally {
            CoreLoggerContexts.stopLoggerContext(false);
        }
        final int LINESEP = System.getProperty("line.separator").length();
        assertEquals("Shrunk to actual used size", 474 + 2 * LINESEP, f.length());
        
        String line1, line2, line3;
        try (final BufferedReader reader = new BufferedReader(new FileReader(LOGFILE))) {
            line1 = reader.readLine();
            line2 = reader.readLine();
            line3 = reader.readLine();
        }
        assertNotNull(line1);
        assertThat(line1, containsString("Test log1"));
        final String location1 = "org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderLocationTest.testMemMapLocation(MemoryMappedFileAppenderLocationTest.java:65)";
        assertThat(line1, containsString(location1));

        assertNotNull(line2);
        assertThat(line2, containsString("Test log2"));
        final String location2 = "org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderLocationTest.testMemMapLocation(MemoryMappedFileAppenderLocationTest.java:69)";
        assertThat(line2, containsString(location2));

        assertNull("only two lines were logged", line3);
    } 
                            #location 23 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Test
    public void testMemMapLocation() throws Exception {
        final File f = new File(LOGFILE);
        if (f.exists()) {
            assertTrue(f.delete());
        }
        assertTrue(!f.exists());
        
        final int expectedFileLength = Integers.ceilingNextPowerOfTwo(32000);
        assertEquals(32768, expectedFileLength);
        
        final Logger log = LogManager.getLogger();
        try {
            log.warn("Test log1");
            assertTrue(f.exists());
            assertEquals("initial length", expectedFileLength, f.length());
            
            log.warn("Test log2");
            assertEquals("not grown", expectedFileLength, f.length());
        } finally {
            CoreLoggerContexts.stopLoggerContext(false);
        }
        final int LINESEP = System.lineSeparator().length();
        assertEquals("Shrunk to actual used size", 474 + 2 * LINESEP, f.length());
        
        String line1, line2, line3;
        try (final BufferedReader reader = new BufferedReader(new FileReader(LOGFILE))) {
            line1 = reader.readLine();
            line2 = reader.readLine();
            line3 = reader.readLine();
        }
        assertNotNull(line1);
        assertThat(line1, containsString("Test log1"));
        final String location1 = "org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderLocationTest.testMemMapLocation(MemoryMappedFileAppenderLocationTest.java:65)";
        assertThat(line1, containsString(location1));

        assertNotNull(line2);
        assertThat(line2, containsString("Test log2"));
        final String location2 = "org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderLocationTest.testMemMapLocation(MemoryMappedFileAppenderLocationTest.java:69)";
        assertThat(line2, containsString(location2));

        assertNull("only two lines were logged", line3);
    }