# HG changeset patch # User Michał Kępień # Date 1537815849 -7200 # Node ID c5665d3191aa5250d4b5c44a4ecc50efd5a49140 # Parent 4ddd6f5c3ffcf471ed93e49fa1b392cf997f9926 Prevent assigning negative values to unsigned variables diff -r 4ddd6f5c3ffc -r c5665d3191aa mcabber/mcabber/screen.c --- a/mcabber/mcabber/screen.c Sun Sep 23 22:52:29 2018 +0200 +++ b/mcabber/mcabber/screen.c Mon Sep 24 21:04:09 2018 +0200 @@ -917,7 +917,8 @@ guint scr_gettextwidth(void) { - return maxX - Roster_Width - scr_getprefixwidth(); + int used_width = Roster_Width + scr_getprefixwidth(); + return maxX > used_width ? maxX - used_width : 0; } guint scr_gettextheight(void) @@ -1094,8 +1095,7 @@ g_free(id); } else { // Load buddy history from file (if enabled) tmp->bd = g_new0(buffdata, 1); - hlog_read_history(title, &tmp->bd->hbuf, - maxX - Roster_Width - scr_getprefixwidth()); + hlog_read_history(title, &tmp->bd->hbuf, scr_gettextwidth()); // Set a readmark to separate new content hbuf_set_readmark(tmp->bd->hbuf, TRUE); @@ -1536,8 +1536,7 @@ g_free(nicktmp); } hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, - maxX - Roster_Width - scr_getprefixwidth(), num_history_blocks, - mucnicklen, xep184); + scr_gettextwidth(), num_history_blocks, mucnicklen, xep184); g_free(text_locale); if (win_entry->bd->cleared) {