Skip to content

Commit

Permalink
fix the bug of getInt2 reported by #287
Browse files Browse the repository at this point in the history
  • Loading branch information
lionsoul2014 committed Feb 5, 2023
1 parent d0550cc commit 767fad8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion binding/java/pom.xml
Expand Up @@ -4,7 +4,7 @@

<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>2.6.6</version>
<version>2.7.0</version>
<packaging>jar</packaging>

<name>ip2region</name>
Expand Down Expand Up @@ -41,6 +41,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>

<dependencies>
Expand Down
Expand Up @@ -235,8 +235,8 @@ public static int getInt(byte[] b, int offset) {

public static int getInt2(byte[] b, int offset) {
return (
(b[offset++] & 0x000000FF) |
(b[offset ] & 0x0000FF00)
((b[offset++] & 0x000000FF)) |
((b[offset ] << 8) & 0x0000FF00)
);
}

Expand Down
2 changes: 2 additions & 0 deletions maker/java/pom.xml
Expand Up @@ -41,6 +41,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions maker/java/src/main/java/org/lionsoul/ip2region/xdb/Util.java
Expand Up @@ -36,8 +36,8 @@ public static long getIntLong(byte[] b, int offset) {

public static int getInt2(byte[] b, int offset) {
return (
(b[offset++] & 0x000000FF) |
(b[offset ] & 0x0000FF00)
((b[offset++]) & 0x000000FF) |
((b[offset ] << 8) & 0x0000FF00)
);
}

Expand Down

0 comments on commit 767fad8

Please sign in to comment.