From 16049194444f9acc27b9ed6b8de6b39651c5a8fd Mon Sep 17 00:00:00 2001 From: Test_User Date: Sun, 26 Nov 2023 02:19:27 -0500 Subject: Fix memory errors, disable spam command --- commands.c | 2 +- main.c | 1 - table.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/commands.c b/commands.c index 33ffd21..f325457 100644 --- a/commands.c +++ b/commands.c @@ -243,7 +243,7 @@ int init_user_commands(void) { set_table_index(&user_commands, STRING("sus"), &sus_command_def); set_table_index(&user_commands, STRING("cr"), &cr_command_def); set_table_index(&user_commands, STRING("help"), &help_command_def); - set_table_index(&user_commands, STRING("spam"), &spam_command_def); +// set_table_index(&user_commands, STRING("spam"), &spam_command_def); set_table_index(&user_commands, STRING("clear"), &clear_command_def); return 0; diff --git a/main.c b/main.c index 6aff2de..a5401b5 100644 --- a/main.c +++ b/main.c @@ -45,7 +45,6 @@ void *client_loop(void *ign) { pthread_mutex_lock(&send_lock); listen(client_listen_fd, 0); client_connected = 0; - client_nick.data = malloc(0); while (1) { char data[512]; pthread_mutex_unlock(&send_lock); // TODO: proper locking, this works for now but is certainly inefficient diff --git a/table.c b/table.c index a4adf61..d80d7fd 100644 --- a/table.c +++ b/table.c @@ -161,7 +161,7 @@ void * remove_table_index(struct table *tbl, struct string name) { void *ptr = tbl->array[index].ptr; free(tbl->array[index].name.data); - memmove(&(tbl->array[index]), &(tbl->array[index+1]), (tbl->len - index) * sizeof(*(tbl->array))); + memmove(&(tbl->array[index]), &(tbl->array[index+1]), (tbl->len - index - 1) * sizeof(*(tbl->array))); tbl->len--; void *tmp = realloc(tbl->array, sizeof(*(tbl->array)) * tbl->len); -- cgit v1.2.3