summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2023-11-26 02:19:27 -0500
committerTest_User <hax@andrewyu.org>2023-11-26 02:19:27 -0500
commit16049194444f9acc27b9ed6b8de6b39651c5a8fd (patch)
tree968f2a253b8093b454f58a5491a62e2515161941
parentf79a5dbfbadf78baf5683eede02a8454e403f58e (diff)
downloadcoupserv-16049194444f9acc27b9ed6b8de6b39651c5a8fd.tar.gz
coupserv-16049194444f9acc27b9ed6b8de6b39651c5a8fd.zip
Fix memory errors, disable spam command
-rw-r--r--commands.c2
-rw-r--r--main.c1
-rw-r--r--table.c2
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);