fixed server receive code param error
All checks were successful
Test Project / test-project (./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./test) (push) Successful in 1m49s
Codacy Scan / Codacy Security Scan (push) Successful in 2m22s
Test WHY2-core / test-why2 (why2, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-core-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m22s
Test WHY2-logger / test-why2 (why2-logger, ./configure.sh, gdb -ex "run" -ex "quit" --batch, ubuntu-latest, ./out/why2-logger-test, valgrind --leak-check=full --show-leak-kinds=reachable --track-origins=yes -s) (push) Successful in 2m33s
Build WHY2-chat / test-why2 (./out/why2-chat-client, ./configure.sh, ubuntu-latest, ./out/why2-chat-server) (push) Successful in 3m20s

This commit is contained in:
Václav Šmejkal 2025-01-31 14:31:30 +01:00
parent c0c0ad6894
commit b392451486
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -704,10 +704,8 @@ void *why2_communicate_thread(void *arg)
decoded_code_buffer = get_string_from_json_string(raw, "code"); //DECODE
//TRIM MESSAGE
why2_trim_string(&decoded_buffer);
if (decoded_buffer != NULL) why2_trim_string(&decoded_buffer);
if (decoded_buffer != NULL && strlen(decoded_buffer) != 0)
{
if (decoded_code_buffer != NULL) //CODES FROM CLIENT
{
if (strcmp(decoded_code_buffer, WHY2_CHAT_CODE_EXIT) == 0) //USER REQUESTED EXIT
@ -765,7 +763,7 @@ void *why2_communicate_thread(void *arg)
//DEALLOCATION
why2_deallocate(message);
} else if (strcmp(decoded_code_buffer, WHY2_CHAT_CODE_PM) == 0) //PM
} else if (strcmp(decoded_code_buffer, WHY2_CHAT_CODE_PM) == 0 && decoded_buffer != NULL && strlen(decoded_buffer) != 0) //PM
{
char *id = NULL; //RECEIVER
char *msg;
@ -825,7 +823,7 @@ void *why2_communicate_thread(void *arg)
}
//IGNORE INVALID CODES, THE USER JUST GOT THEIR LOBOTOMY DONE
} else if (strncmp(decoded_buffer, WHY2_CHAT_COMMAND_PREFIX, strlen(WHY2_CHAT_COMMAND_PREFIX)) != 0) //IGNORE MESSAGES BEGINNING WITH '!'
} else if (decoded_buffer != NULL && strlen(decoded_buffer) != 0 && strncmp(decoded_buffer, WHY2_CHAT_COMMAND_PREFIX, strlen(WHY2_CHAT_COMMAND_PREFIX)) != 0) //IGNORE MESSAGES BEGINNING WITH '!'
{
//REBUILD MESSAGE WITH USERNAME
json_object_object_add(json, "message", json_object_new_string(decoded_buffer));
@ -839,7 +837,6 @@ void *why2_communicate_thread(void *arg)
send_to_all(raw_output); //e
}
}
deallocation: