diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 0c13b2ef7..21ceff6b5 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,6 +1,6 @@ /* 6.2.1.19 20181023 * Fix header file execution order by renaming user_config.h to my_user_config.h - * Fix invalid JSON floating point result from nan into null (#4147) + * Fix invalid JSON floating point result from nan (Not a Number) and inf (Infinity) into null (#4147) * * 6.2.1.18 20181019 * Add more API callbacks and document API.md diff --git a/sonoff/support.ino b/sonoff/support.ino index 1e960bb16..83c154834 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -196,7 +196,7 @@ int TextToInt(char *str) char* dtostrfd(double number, unsigned char prec, char *s) { - if (isnan(number)) { + if ((isnan(number)) || (isinf(number))) { // Fix for JSON output (https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript) strcpy(s, "null"); return s; } else {