From c95170f25a0d22a29a710f1832333eab232a3b9c Mon Sep 17 00:00:00 2001 From: nova Date: Mon, 7 Sep 2026 18:28:12 +0200 Subject: [PATCH] fix of regression, no longer crashes on resizing window --- threading.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/threading.c b/threading.c index 7125d58..69f0f0f 100644 --- a/threading.c +++ b/threading.c @@ -338,7 +338,7 @@ void *thread_top(){ } void *thread_btm(){ char *path = NULL; - char *ui_btm_right_block = malloc(sizeof(char)); + char *ui_btm_right_block = NULL; char fmt[] = "%0.2lf%c %s %0.2lf%c %s"; /*using a pointer here would put it into ROM, causing a segfault at the edit below*/ unsigned int ui_btm_right_block_size = 0; unsigned int buffer_width = 0; @@ -370,7 +370,6 @@ void *thread_btm(){ pthread_mutex_unlock(&mutex_mid); - free(ui_btm_right_block); if(path) { free(path); @@ -418,9 +417,11 @@ void *thread_btm(){ } else { fmt[15] = '2'; } - ui_btm_right_block = malloc(ui_btm_right_block_size * 2); - ui_btm_right_block_size = sprintf(ui_btm_right_block, fmt, parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left); + free(ui_btm_right_block); + ui_btm_right_block = malloc(buffer_width); + ui_btm_right_block_size = snprintf(ui_btm_right_block, buffer_width, fmt, parsed_number[0], size_unit[(unsigned)size_index[0]], ui_btm_current_dir_size, parsed_number[1], size_unit[(unsigned)size_index[1]], ui_btm_text_storage_left); /*}}}*/ + } memset(btm_buffer, ' ', buffer_width);