Skip to content

Commit d37361f

Browse files
committed
Fix NegativeArrayException
1 parent feaeaf3 commit d37361f

7 files changed

Lines changed: 33 additions & 21 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
1313
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
1414

1515

16-
version = "1.0.2"
16+
version = "1.0.3"
1717
group = "ru.lionzxy.fastlogblock" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1818
archivesBaseName = "FastLogBlock"
1919

gradle/wrapper/gradle-wrapper.jar

1.07 KB
Binary file not shown.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sun Jan 21 21:37:17 MSK 2018
1+
#Sun Jan 26 20:15:46 MSK 2020
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
23
distributionBase=GRADLE_USER_HOME
34
distributionPath=wrapper/dists
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
6+
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/ru/lionzxy/fastlogblock/io/mappers/BlockMapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ protected void writeToFile(final OutputStream outputStream) throws IOException {
5757
private void putFromByte(final TByteArrayList byteArrayList) {
5858
final ByteBuffer byteBuffer = ByteBuffer.wrap(byteArrayList.toArray());
5959
final long blockid = byteBuffer.getLong();
60+
int nameSize = byteArrayList.size() - Long.BYTES - 1;
6061

61-
final byte[] tmpbuffer = new byte[byteArrayList.size() - Long.BYTES - 1];
62+
if (nameSize <= 0) {
63+
return;
64+
}
65+
66+
final byte[] tmpbuffer = new byte[nameSize];
6267
byteBuffer.get(tmpbuffer);
6368
final ASCIString asciString = new ASCIString(tmpbuffer);
6469
blockToId.put(asciString, blockid);

src/main/java/ru/lionzxy/fastlogblock/io/mappers/NickMapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ public NickMapper(final File mapFile) throws IOException {
3434
private void putFromByte(final TByteArrayList byteArrayList) {
3535
final ByteBuffer byteBuffer = ByteBuffer.wrap(byteArrayList.toArray());
3636
final int userid = byteBuffer.getInt();
37+
int nameSize = byteArrayList.size() - Integer.BYTES - 1;
3738

38-
final byte[] tmpbuffer = new byte[byteArrayList.size() - 5];
39+
if (nameSize <= 0) {
40+
return;
41+
}
42+
43+
final byte[] tmpbuffer = new byte[nameSize];
3944
byteBuffer.get(tmpbuffer);
4045
final ASCIString asciString = new ASCIString(tmpbuffer);
4146
uuidToId.put(asciString, userid);

0 commit comments

Comments
 (0)