From 5e23c32ae81a9b91436333d7d21c79fe38b46af3 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 15 Dec 2024 07:53:24 -0500 Subject: [PATCH] build: Fix a potential null dereference? --- src/ssb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ssb.c b/src/ssb.c index 614ef94d..3b7c42bc 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -2862,6 +2862,10 @@ static void _tf_ssb_connection_tunnel_callback( tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char* portal_id, int32_t request_number, const char* target_id, int connect_flags) { tf_ssb_connection_t* connection = tf_ssb_connection_get(ssb, portal_id); + if (!connection) + { + return NULL; + } JSContext* context = ssb->context; tf_ssb_connection_t* tunnel = tf_malloc(sizeof(tf_ssb_connection_t)); @@ -4446,8 +4450,7 @@ bool tf_ssb_tunnel_create(tf_ssb_t* ssb, const char* portal_id, const char* targ tf_ssb_connection_rpc_send_json(connection, k_ssb_rpc_flag_stream | k_ssb_rpc_flag_new_request, request_number, "tunnel.connect", message, NULL, NULL, NULL); JS_FreeValue(context, message); - tf_ssb_connection_tunnel_create(ssb, portal_id, request_number, target_id, connect_flags); - return true; + return tf_ssb_connection_tunnel_create(ssb, portal_id, request_number, target_id, connect_flags) != NULL; } return false; }