[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ncurses 6.1 _nc_printf_string_sp NULL screen pointer handling
From: |
Steven Noonan |
Subject: |
ncurses 6.1 _nc_printf_string_sp NULL screen pointer handling |
Date: |
Mon, 12 Feb 2018 15:07:58 -0800 |
User-agent: |
Mutt/1.9.3 (2018-01-21) |
It seems that the majority of the functions in ncurses 6.1 are able to handle a
NULL screen pointer by simply returning an error code.
This call stack does not handle it properly, however:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b9045f in _nc_printf_string_sp (sp=0x0, fmt=0x8865a0 "%s",
ap=0x7fffffffa070) at ../ncurses/./base/safe_sprintf.c:251
251 if (screen_lines(SP_PARM) > MyRows || screen_columns(SP_PARM) >
MyCols) {
(gdb) bt full
#0 0x00007ffff7b9045f in _nc_printf_string_sp (sp=0x0, fmt=0x8865a0 "%s",
ap=0x7fffffffa070) at ../ncurses/./base/safe_sprintf.c:251
result = 0x0
#1 0x00007ffff7b86b6a in vwprintw (win=0x0, fmt=0x8865a0 "%s",
argp=0x7fffffffa070) at ../ncurses/./base/lib_printw.c:143
buf = 0x0
code = -1
sp = 0x0
#2 0x00007ffff7b868e6 in wprintw (win=0x0, fmt=0x8865a0 "%s") at
../ncurses/./base/lib_printw.c:80
argp = {{
gp_offset = 16,
fp_offset = 48,
overflow_arg_area = 0x7fffffffa150,
reg_save_area = 0x7fffffffa090
}}
code = 0
It seems like this would fix the issue (works locally at any rate):
diff --git a/ncurses/base/safe_sprintf.c b/ncurses/base/safe_sprintf.c
index 34abd2f..d0dbefd 100644
--- a/ncurses/base/safe_sprintf.c
+++ b/ncurses/base/safe_sprintf.c
@@ -247,6 +247,8 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
#else
#define MyCols _nc_globals.safeprint_cols
#define MyRows _nc_globals.safeprint_rows
+ if (!SP_PARM)
+ return NULL;
if (screen_lines(SP_PARM) > MyRows || screen_columns(SP_PARM) > MyCols)
{
if (screen_lines(SP_PARM) > MyRows)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ncurses 6.1 _nc_printf_string_sp NULL screen pointer handling,
Steven Noonan <=