diff mbox series

[5/6] util: Handle NULL pointers in l_safe_ato* functions

Message ID 20240823161553.479576-5-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/6] netlink: Add l_netlink_iter | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success

Commit Message

Denis Kenzior Aug. 23, 2024, 4:15 p.m. UTC
---
 ell/util.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/ell/util.c b/ell/util.c
index 45ec6c8110bc..f474098c082b 100644
--- a/ell/util.c
+++ b/ell/util.c
@@ -760,6 +760,9 @@  static int safe_atou(const char *s, int base, unsigned int *out_u)
 
 LIB_EXPORT int l_safe_atou32(const char *s, uint32_t *out_u)
 {
+	if (unlikely(!s))
+		return -EINVAL;
+
 	if (!l_ascii_isdigit(s[0]))
 		return -EINVAL;
 
@@ -808,6 +811,9 @@  LIB_EXPORT int l_safe_atox16(const char *s, uint16_t *out_x)
 
 LIB_EXPORT int l_safe_atox32(const char *s, uint32_t *out_x)
 {
+	if (unlikely(!s))
+		return -EINVAL;
+
 	if (!l_ascii_isxdigit(s[0]))
 		return -EINVAL;