diff options
author | David Robillard <d@drobilla.net> | 2024-12-11 18:34:20 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-12-11 19:39:22 -0500 |
commit | 5dc6a712ef2cc383083220326354fc7aa960c798 (patch) | |
tree | de4fdfb1102436bd6f431a35df6e5189424551df /src | |
parent | 45368fc65aebc892bff3ab4b3e844512af26b566 (diff) | |
download | lilv-5dc6a712ef2cc383083220326354fc7aa960c798.tar.gz lilv-5dc6a712ef2cc383083220326354fc7aa960c798.tar.bz2 lilv-5dc6a712ef2cc383083220326354fc7aa960c798.zip |
Avoid use of atoi()
Diffstat (limited to 'src')
-rw-r--r-- | src/.clang-tidy | 1 | ||||
-rw-r--r-- | src/world.c | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy index 6fc648d..9cc7cdc 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -6,7 +6,6 @@ Checks: > -android-cloexec-fopen, -bugprone-narrowing-conversions, -cert-err33-c, - -cert-err34-c, -clang-analyzer-optin.core.EnumCastOutOfRange, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-valist.Uninitialized, diff --git a/src/world.c b/src/world.c index c23a34e..42e644c 100644 --- a/src/world.c +++ b/src/world.c @@ -19,6 +19,7 @@ #include <zix/tree.h> #include <assert.h> +#include <limits.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -733,8 +734,14 @@ get_version(const LilvWorld* world, SordModel* model, const LilvNode* subject) LilvVersion version = {0, 0}; if (minor_node && micro_node) { - version.minor = atoi((const char*)sord_node_get_string(minor_node)); - version.micro = atoi((const char*)sord_node_get_string(micro_node)); + const char* const minor_str = (const char*)sord_node_get_string(minor_node); + const char* const micro_str = (const char*)sord_node_get_string(micro_node); + const long minor = strtol(minor_str, NULL, 10); + const long micro = strtol(micro_str, NULL, 10); + if (minor >= 0 && minor < INT_MAX && micro >= 0 && micro < INT_MAX) { + version.minor = (int)minor; + version.micro = (int)micro; + } } return version; |