summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9e2dd42)
raw | patch | inline | side by side (parent: 9e2dd42)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 14:44:18 +0000 (15:44 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 31 Oct 2010 14:44:18 +0000 (15:44 +0100) |
src/common.c | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 1cef5e1756258b75dc6fc4cd89f28522daa9851d..87d7bf0833e18fafde04d34555a86cbfd6c4afab 100644 (file)
--- a/src/common.c
+++ b/src/common.c
if (strcmp ("N", ptr) == 0)
vl->time = cdtime ();
else
- /* FIXME: Add error checking here. */
- vl->time = DOUBLE_TO_CDTIME_T (atof (ptr));
+ {
+ char *endptr = NULL;
+ double tmp;
+
+ errno = 0;
+ tmp = strtod (ptr, &endptr);
+ if ((errno != 0) /* Overflow */
+ || (endptr == ptr) /* Invalid string */
+ || (endptr == NULL) /* This should not happen */
+ || (*endptr != 0)) /* Trailing chars */
+ return (-1);
+
+ vl->time = DOUBLE_TO_CDTIME_T (tmp);
+ }
}
else
{