json BUGFIX in ::lyjson_number_is_zero()
diff --git a/src/json.c b/src/json.c
index 6ae4484..3e36b0f 100644
--- a/src/json.c
+++ b/src/json.c
@@ -355,8 +355,6 @@
/**
* @brief Check if the number can be shortened to zero.
*
- * The input number must be syntactically valid.
- *
* @param[in] in Start of input string;
* @param[in] end End of input string;
* @return 1 if number is zero, otherwise 0.
@@ -364,13 +362,17 @@
static ly_bool
lyjson_number_is_zero(const char *in, const char *end)
{
- assert(end >= in);
+ assert(in < end);
if ((in[0] == '-') || (in[0] == '+')) {
in++;
+ assert(in < end);
}
if ((in[0] == '0') && (in[1] == '.')) {
in += 2;
+ if (!(in < end)) {
+ return 1;
+ }
}
return lyjson_count_in_row(in, end, '0', 0) == end - in;