diff mbox series

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

Message ID 20230123235649.3231488-3-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit be5c49385e4d8403d773b2838369a5987e732ff0
Headers show
Series [BlueZ,1/5] profiles: Add Support for Metadata, CID and VID | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

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);