WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/simdjson/NumberParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ float parseFloat(byte[] buffer, int len, int offset) {
currentIdx = digitsParsingResult.currentIdx();
int digitCount = currentIdx - digitsStartIdx;
if (digitCount == 0) {
if (checkIfNull(buffer, len, offset)) return Float.NaN;
throw new JsonParsingException("Invalid number. Minus has to be followed by a digit.");
}
if ('0' == buffer[digitsStartIdx] && digitCount > 1) {
Expand Down Expand Up @@ -273,6 +274,7 @@ float parseFloat(byte[] buffer, int len, int offset) {
currentIdx = digitsParsingResult.currentIdx();
int digitCount = currentIdx - digitsStartIdx;
if (digitCount == 0) {
if (checkIfNull(buffer, len, offset)) return Double.NaN;
throw new JsonParsingException("Invalid number. Minus has to be followed by a digit.");
}
if ('0' == buffer[digitsStartIdx] && digitCount > 1) {
Expand Down Expand Up @@ -360,4 +362,11 @@ int currentIdx() {
return currentIdx;
}
}

private boolean checkIfNull(byte[] buffer, int len, int offset) {
boolean statsWithN = buffer[offset] == 'n' || buffer[offset] == 'N';
boolean endsWithL = buffer[offset + 3] == 'l' || buffer[offset + 3] == 'L';
return statsWithN && endsWithL;
}

}