mirror of
https://github.com/kgabis/parson.git
synced 2024-11-24 06:05:29 +00:00
Using isnan and isinf macros if they are defined (fixes issue #104).
This commit is contained in:
parent
4f3eaa6849
commit
b58ac757a8
8
parson.c
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…
Reference in New Issue
Block a user