8000 Fixed `JsonVariant::is<int>()` that returned true for empty strings · janelia-arduino/ArduinoJson@fa1a40a · GitHub
[go: up one dir, main page]

Skip to content

Commit fa1a40a

Browse files
committed
Fixed JsonVariant::is<int>() that returned true for empty strings
1 parent 954428e commit fa1a40a

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ HEAD
55
----
66

77
* Improved float serialization when `-fsingle-precision-constant` is used
8+
* Fixed `JsonVariant::is<int>()` that returned true for empty strings
89

910
v5.13.2
1011
-------

src/ArduinoJson/Polyfills/isInteger.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ namespace ArduinoJson {
1010
namespace Internals {
1111

1212
inline bool isInteger(const char* s) {
13-
if (!s) return false;
13+
if (!s || !*s) return false;
1414
if (issign(*s)) s++;
1515
while (isdigit(*s)) s++;
1616
return *s == '\0';
1717
}
18-
}
19-
}
18+
} // namespace Internals
19+
} // namespace ArduinoJson

test/Polyfills/isInteger.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ TEST_CASE("isInteger()") {
1212
REQUIRE_FALSE(isInteger(NULL));
1313
}
1414

15+
SECTION("Empty String") {
16+
REQUIRE_FALSE(isInteger(""));
17+
}
18+
1519
SECTION("FloatNotInteger") {
1620
REQUIRE_FALSE(isInteger("3.14"));
1721
REQUIRE_FALSE(isInteger("-3.14"));

0 commit comments

Comments
 (0)
0