aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-12-21 18:26:55 +0000
committerDavid Robillard <d@drobilla.net>2012-12-21 18:26:55 +0000
commit73d0a86698528bf73d029e35a57ce7b38783cf2a (patch)
treecee6ad10793da41e78b3324a935c7cf94b1293fa /src/node.c
parent9d36ba3e802705b1d6236eefc99916af6116a448 (diff)
downloadserd-73d0a86698528bf73d029e35a57ce7b38783cf2a.tar.gz
serd-73d0a86698528bf73d029e35a57ce7b38783cf2a.tar.bz2
serd-73d0a86698528bf73d029e35a57ce7b38783cf2a.zip
Fix crash when serd_node_new_decimal is called with infinity or NaN.
git-svn-id: http://svn.drobilla.net/serd/trunk@401 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/node.c b/src/node.c
index 7f6e9863..061903bc 100644
--- a/src/node.c
+++ b/src/node.c
@@ -211,6 +211,10 @@ SERD_API
SerdNode
serd_node_new_decimal(double d, unsigned frac_digits)
{
+ if (isnan(d) || isinf(d)) {
+ return SERD_NODE_NULL;
+ }
+
const double abs_d = fabs(d);
const unsigned int_digits = (unsigned)fmax(1.0, ceil(log10(abs_d + 1)));
char* buf = (char*)calloc(int_digits + frac_digits + 3, 1);