#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_screen.c,v 1.35 2009/06/06 20:26:17 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.38 2009/10/24 22:08:55 tom Exp $")
#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
WINDOW tmp, *nwin;
int n;
- T((T_CALLED("getwin(%p)"), filep));
+ T((T_CALLED("getwin(%p)"), (void *) filep));
clearerr(filep);
- (void) fread(&tmp, sizeof(WINDOW), 1, filep);
- if (ferror(filep)
+ if (fread(&tmp, 1, sizeof(WINDOW), filep) < sizeof(WINDOW)
+ || ferror(filep)
|| tmp._maxy == 0
|| tmp._maxy > MAX_SIZE
|| tmp._maxx == 0
- || tmp._maxx > MAX_SIZE)
+ || tmp._maxx > MAX_SIZE) {
returnWin(0);
+ }
if (tmp._flags & _ISPAD) {
nwin = NCURSES_SP_NAME(newpad) (NCURSES_SP_ARGx
- tmp._maxy + 1, tmp._maxx + 1);
+ tmp._maxy + 1,
+ tmp._maxx + 1);
} else {
nwin = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx
tmp._maxy + 1,
* made sense is probably gone.
*/
if (nwin != 0) {
+ size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1);
+
nwin->_curx = tmp._curx;
nwin->_cury = tmp._cury;
nwin->_maxy = tmp._maxy;
for (n = 0; n <= nwin->_maxy; n++) {
clearerr(filep);
- (void) fread(nwin->_line[n].text,
- sizeof(NCURSES_CH_T),
- (size_t) (nwin->_maxx + 1),
- filep);
- if (ferror(filep)) {
+ if (fread(nwin->_line[n].text, 1, linesize, filep) < linesize
+ || ferror(filep)) {
delwin(nwin);
returnWin(0);
}
int code = ERR;
int n;
- T((T_CALLED("putwin(%p,%p)"), win, filep));
+ T((T_CALLED("putwin(%p,%p)"), (void *) win, (void *) filep));
if (win != 0) {
size_t len = (size_t) (win->_maxx + 1);
{
FILE *fp = 0;
- T((T_CALLED("scr_restore(%p,%s)"), SP_PARM, _nc_visbuf(file)));
+ T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
if (_nc_access(file, R_OK) < 0
|| (fp = fopen(file, "rb")) == 0) {
FILE *fp = 0;
int code = ERR;
- T((T_CALLED("scr_init(%p,%s)"), SP_PARM, _nc_visbuf(file)));
+ T((T_CALLED("scr_init(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
if (SP_PARM != 0 &&
#ifdef USE_TERM_DRIVER
NCURSES_EXPORT(int)
NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file)
{
- T((T_CALLED("scr_set(%p,%s)"), SP_PARM, _nc_visbuf(file)));
+ T((T_CALLED("scr_set(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
if (NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == ERR) {
returnCode(ERR);