From 3c687dc780bf7a887296e686b0e5e165330a6f8d Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 11 Jan 2023 01:55:23 +0000 Subject: [PATCH] A room.attendants left message with no id crashes some other clients. :/ git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4114 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/ssb.rpc.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index f4a319f9..fa3d95bb 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -1012,30 +1012,30 @@ static void _tf_ssb_rpc_connections_changed_callback(tf_ssb_t* ssb, tf_ssb_chang { tf_ssb_remove_blob_want_added_callback(ssb, _tf_ssb_rpc_blob_wants_added_callback, connection); - JSValue left = JS_NewObject(context); - JS_SetPropertyStr(context, left, "type", JS_NewString(context, "left")); char id[k_id_base64_len] = ""; if (tf_ssb_connection_get_id(connection, id, sizeof(id))) { + JSValue left = JS_NewObject(context); + JS_SetPropertyStr(context, left, "type", JS_NewString(context, "left")); JS_SetPropertyStr(context, left, "id", JS_NewString(context, id)); - } - tf_ssb_connection_t* connections[1024]; - int count = tf_ssb_get_connections(ssb, connections, _countof(connections)); - for (int i = 0; i < count; i++) - { - if (tf_ssb_connection_is_attendant(connections[i])) + tf_ssb_connection_t* connections[1024]; + int count = tf_ssb_get_connections(ssb, connections, _countof(connections)); + for (int i = 0; i < count; i++) { - tf_ssb_connection_rpc_send_json( - connections[i], - k_ssb_rpc_flag_stream, - -tf_ssb_connection_get_attendant_request_number(connections[i]), - left, - NULL, - NULL, - NULL); + if (tf_ssb_connection_is_attendant(connections[i])) + { + tf_ssb_connection_rpc_send_json( + connections[i], + k_ssb_rpc_flag_stream, + -tf_ssb_connection_get_attendant_request_number(connections[i]), + left, + NULL, + NULL, + NULL); + } } + JS_FreeValue(context, left); } - JS_FreeValue(context, left); } }