diff mbox series

[BlueZ,3/5] shared/util: Check arguments on util_memcpy

Message ID 20230123235649.3231488-3-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,1/5] profiles: Add Support for Metadata, CID and VID | expand

Commit Message

Luiz Augusto von Dentz Jan. 23, 2023, 11:56 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This avoids having to check for !src or !len before calling util_memcpy
since otherwise it can cause runtime errors.
---
 src/shared/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/shared/util.c b/src/shared/util.c
index 69abfba31978..89f1a2623cc8 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -221,7 +221,7 @@  int util_iov_memcmp(const struct iovec *iov1, const struct iovec *iov2)
 
 void util_iov_memcpy(struct iovec *iov, void *src, size_t len)
 {
-	if (!iov)
+	if (!iov || !src || !len)
 		return;
 
 	iov->iov_base = realloc(iov->iov_base, len);