summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-11-06 10:32:42 +0100
committerGravatar Nikias Bassen2026-11-06 10:32:42 +0100
commita3215e2a6577df39d944578af671f9dae2770336 (patch)
tree8eb43882cc84d851cdc12e454d71fdbb21b4bb29 /src
parent1d3b54c784da260f71d885f5f560d69c211a645e (diff)
downloadlibplist-a3215e2a6577df39d944578af671f9dae2770336.tar.gz
libplist-a3215e2a6577df39d944578af671f9dae2770336.tar.bz2
plist: treat NaN date values as 0 in plist_get_date_val
Converting NaN to int32_t is undefined behavior, and NaN can come from a parsed date node.
Diffstat (limited to 'src')
-rw-r--r--src/plist.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/plist.c b/src/plist.c
index 85c2338..ea3a247 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -1891,6 +1891,8 @@ void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec)
assert(length == sizeof(double));
/* Inverse of plist_set_date_val (val = sec + usec / 1000000):
* whole seconds rounded down, the fraction rounded to microseconds. */
+ if (isnan(val))
+ val = 0;
double whole = floor(val);
double frac_usec = round((val - whole) * 1000000);
if (frac_usec >= 1000000) {