aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-24 16:17:05 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-04-24 16:17:05 -0400
commitf074cf9ea6d8ab8f2ad6681e8c2a39bcd32f7f0e (patch)
tree2537e012a470a4f96a9d6441412b77ccc9f1a6f4 /src/lib
parent32e8aa87ba1f592f31f5a94b2d35bf2159071ae0 (diff)
downloadstasis-f074cf9ea6d8ab8f2ad6681e8c2a39bcd32f7f0e.tar.gz
Fix error check for strtof/d/ld calls
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/core/strlist.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/core/strlist.c b/src/lib/core/strlist.c
index a9a95e7..42d5b85 100644
--- a/src/lib/core/strlist.c
+++ b/src/lib/core/strlist.c
@@ -679,8 +679,8 @@ float strlist_item_as_float(struct StrList *pStrList, size_t index) {
char *error_p;
strlist_clear_error();
- float result = (float) strtof(strlist_item(pStrList, index), &error_p);
- if (!result && error_p && *error_p != 0) {
+ const float result = strtof(strlist_item(pStrList, index), &error_p);
+ if ((result == FLT_MIN || result == HUGE_VALF) && errno == ERANGE) {
strlist_set_error(STRLIST_E_INVALID_VALUE);
return 0;
}
@@ -698,8 +698,8 @@ double strlist_item_as_double(struct StrList *pStrList, size_t index) {
char *error_p;
strlist_clear_error();
- double result = (double) strtod(strlist_item(pStrList, index), &error_p);
- if (!result && error_p && *error_p != 0) {
+ const double result = strtod(strlist_item(pStrList, index), &error_p);
+ if ((result == DBL_MIN || result == HUGE_VAL) && errno == ERANGE) {
strlist_set_error(STRLIST_E_INVALID_VALUE);
return 0;
}
@@ -717,8 +717,8 @@ long double strlist_item_as_long_double(struct StrList *pStrList, size_t index)
char *error_p;
strlist_clear_error();
- long double result = (long double) strtold(strlist_item(pStrList, index), &error_p);
- if (!result && error_p && *error_p != 0) {
+ const long double result = strtold(strlist_item(pStrList, index), &error_p);
+ if ((result == DBL_MIN || result == HUGE_VALL) && errno == ERANGE) {
strlist_set_error(STRLIST_E_INVALID_VALUE);
return 0;
}