1
0
mirror of https://gittea.dev/nova/th.git synced 2026-01-30 08:40:10 -05:00

-fsanitize=address related stuff

This commit is contained in:
nova
2026-01-17 18:10:01 +01:00
parent f3a39b0df0
commit 1f1de78283
2 changed files with 13 additions and 33 deletions

2
dir.c
View File

@@ -327,7 +327,7 @@ char update_selected_file(){
if (selected_file_current >= mid_file_count) {
selected_file_current = mid_file_count-1;
}
if (selected_file_current != selected_file_last) {
if (selected_file_current != selected_file_last && selected_file_last <= mid_file_count) {
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
ret = 1;
} else {

View File

@@ -417,41 +417,21 @@ void delete(){
werase(win_b);
mvwin(win_b, terminal_height-6, 0);
if (strlen(file_str) < (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION-1) * (terminal_width/3)) {
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3));
memset(btm_buffer, ' ', (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)));
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width);
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text));
if (hits) {
memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str, strlen(file_str));
} else {
btm_buffer[strlen(ui_delete_text)+1] = '"';
memcpy(btm_buffer + strlen(ui_delete_text) +1 + sizeof(char), mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name));
btm_buffer[strlen(ui_delete_text)+1 + sizeof(char) + strlen(mid_content[selected_file_current].file_name)] = '"';
}
memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text));
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3) - (terminal_width/3)) , "(y/N)", strlen("(y/N)"));
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)] = '\0';
/*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/
/*lets hope im never gonna need to format something like this ever again*/
memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str,
(strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ?
((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) :
strlen(file_str)));
} else {
/*since more data is present than can be represented using div3, we do the uncool thing*/
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width);
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text));
/*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/
/*lets hope im never gonna need to format something like this ever again*/
memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str,
(strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ?
((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) :
strlen(file_str)));
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)"));
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width] = '\0';
}
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)"));
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width-1] = '\0';