Using isnan and isinf macros if they are defined (fixes issue #104).

pull/105/head
Krzysztof Gabis 6 years ago
parent 4f3eaa6849
commit b58ac757a8
  1. 8
      parson.c

@ -53,6 +53,12 @@
#undef malloc
#undef free
#if defined(isnan) && defined(isinf)
#define IS_NUMBER_INVALID(x) (isnan((x)) || isinf((x)))
#else
#define IS_NUMBER_INVALID(x) (((x) * 0.0) != 0.0)
#endif
static JSON_Malloc_Function parson_malloc = malloc;
static JSON_Free_Function parson_free = free;
@ -1364,7 +1370,7 @@ JSON_Value * json_value_init_string(const char *string) {
JSON_Value * json_value_init_number(double number) {
JSON_Value *new_value = NULL;
if ((number * 0.0) != 0.0) { /* nan and inf test */
if (IS_NUMBER_INVALID(number)) {
return NULL;
}
new_value = (JSON_Value*)parson_malloc(sizeof(JSON_Value));

Loading…
Cancel
Save