Avoid passing NULL pointers to curses functions.
This allows profanity to work without segfaulting from NULL pointer dereferences when used with NetBSD libcurses. Basic functionality was tested, there may be more NULL pointer issues hiding.
This commit is contained in:
@@ -308,7 +308,9 @@ _inp_win_update_virtual(void)
|
||||
{
|
||||
int wcols = getmaxx(stdscr);
|
||||
int row = screen_inputwin_row();
|
||||
pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols - 2);
|
||||
if (inp_win != NULL) {
|
||||
pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols - 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -95,7 +95,10 @@ rosterwin_roster(void)
|
||||
|
||||
ProfLayoutSplit* layout = (ProfLayoutSplit*)console->layout;
|
||||
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||
werase(layout->subwin);
|
||||
|
||||
if (layout->subwin != NULL) {
|
||||
werase(layout->subwin);
|
||||
}
|
||||
|
||||
char* roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS);
|
||||
if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "first") == 0)) {
|
||||
@@ -1106,9 +1109,11 @@ _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSL
|
||||
|
||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
win_sub_print(layout->subwin, header->str, FALSE, wrap, 1);
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
if (layout->subwin != NULL) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
win_sub_print(layout->subwin, header->str, FALSE, wrap, 1);
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
}
|
||||
|
||||
g_string_free(header, TRUE);
|
||||
}
|
||||
@@ -1166,9 +1171,11 @@ _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title)
|
||||
|
||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
win_sub_print(layout->subwin, header->str, FALSE, wrap, 1);
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
if (layout->subwin != NULL) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
win_sub_print(layout->subwin, header->str, FALSE, wrap, 1);
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
}
|
||||
|
||||
g_string_free(header, TRUE);
|
||||
}
|
||||
|
||||
@@ -1863,7 +1863,12 @@ win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int inden
|
||||
void
|
||||
win_sub_newline_lazy(WINDOW* win)
|
||||
{
|
||||
int curx = getcurx(win);
|
||||
int curx;
|
||||
|
||||
if (win == NULL) {
|
||||
return;
|
||||
}
|
||||
curx = getcurx(win);
|
||||
if (curx > 0) {
|
||||
int cury = getcury(win);
|
||||
wmove(win, cury + 1, 0);
|
||||
|
||||
Reference in New Issue
Block a user