added null check to chat-misc

This commit is contained in:
Václav Šmejkal 2024-02-18 14:26:37 +01:00
parent 64c21ed1fc
commit b1c104247c
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -552,6 +552,9 @@ void *why2_communicate_thread(void *arg)
char *why2_read_socket(int socket) char *why2_read_socket(int socket)
{ {
char *raw_socket = read_socket_raw(socket); char *raw_socket = read_socket_raw(socket);
if (raw_socket == NULL) return NULL;
char *final_message; char *final_message;
struct json_object *json_obj = json_tokener_parse(raw_socket); struct json_object *json_obj = json_tokener_parse(raw_socket);
@ -643,6 +646,8 @@ void *why2_listen_server(void *socket)
{ {
read = why2_read_socket(*((int*) socket)); read = why2_read_socket(*((int*) socket));
if (read == NULL) continue;
if (strncmp(read, WHY2_CHAT_SERVER_USERNAME ": code", 12) == 0) //CODE WAS SENT if (strncmp(read, WHY2_CHAT_SERVER_USERNAME ": code", 12) == 0) //CODE WAS SENT
{ {
if (strcmp(read + 8, WHY2_CHAT_CODE_SSQC) == 0) if (strcmp(read + 8, WHY2_CHAT_CODE_SSQC) == 0)