diff mbox series

[BlueZ,resend,9/9] sdp: Check memory allocation in sdp_copy_seq()

Message ID 20240702142436.833138-10-hadess@hadess.net
State Superseded
Headers show
Series Fix a number of static analysis issues #4 | expand

Commit Message

Bastien Nocera July 2, 2024, 2:23 p.m. UTC
Fix a potential null-dereference if sdp_data_alloc_with_length() fails,
as is done in other similar functions.
---
 lib/sdp.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/lib/sdp.c b/lib/sdp.c
index b87951b007a3..b64245f668d3 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -1538,6 +1538,11 @@  static sdp_data_t *sdp_copy_seq(sdp_data_t *data)
 		value = sdp_data_value(tmp, &len);
 		datatmp = sdp_data_alloc_with_length(tmp->dtd, value, len);
 
+		if (!datatmp) {
+			sdp_data_free(seq);
+			return NULL;
+		}
+
 		if (cur)
 			cur->next = datatmp;
 		else