Skip to content

Commit b58fe1b

Browse files
committed
Fixed metadata pointer bug
1 parent 2e59e12 commit b58fe1b

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/com/maxmind/maxminddb/MaxMindDbReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public MaxMindDbReader(File database, FileMode fileMode) throws IOException {
6666
this.threadBuffer = new ThreadBuffer(database, fileMode);
6767
int start = this.findMetadataStart(database.getName());
6868

69-
Decoder metadataDecoder = new Decoder(this.threadBuffer, 0);
69+
Decoder metadataDecoder = new Decoder(this.threadBuffer, start);
7070
this.metadata = new Metadata(metadataDecoder.decode(start).getNode());
7171
this.decoder = new Decoder(this.threadBuffer,
7272
this.metadata.searchTreeSize + DATA_SECTION_SEPARATOR_SIZE);

src/test/java/com/maxmind/maxminddb/ReaderTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ public void test() throws InvalidDatabaseException, IOException,
4343
}
4444
}
4545

46+
@Test
47+
public void testNoIpV4SearchTree() throws IOException, URISyntaxException {
48+
URI file = ReaderTest.class.getResource(
49+
"/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb")
50+
.toURI();
51+
52+
MaxMindDbReader reader = new MaxMindDbReader(new File(file));
53+
54+
assertEquals("::/64", reader.get(InetAddress.getByName("::1:1.1.1.1"))
55+
.textValue());
56+
}
57+
4658
private void testMetadata(MaxMindDbReader reader, int ipVersion,
4759
long recordSize) {
4860

0 commit comments

Comments
 (0)