X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_print.c;h=aa65041c71d004a80d46b1eace9a8c2d4e0c6230;hp=4accdf6786ea7a7701955d3b5f852e8e82165bff;hb=HEAD;hpb=1f7a36fe16b11bb4aab51be89bbc1b0f75936b78 diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c index 4accdf67..e7d8535e 100644 --- a/ncurses/tinfo/lib_print.c +++ b/ncurses/tinfo/lib_print.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2018-2021,2023 Thomas E. Dickey * * Copyright 1998-2011,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -40,14 +40,14 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_print.c,v 1.28 2020/08/29 16:22:03 juergen Exp $") +MODULE_ID("$Id: lib_print.c,v 1.31 2023/06/10 12:44:41 tom Exp $") NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) /* ship binary character data to the printer via mc4/mc5/mc5p */ { int result; - char *mybuf, *switchon; + char *mybuf = NULL, *switchon; size_t onsize, offsize; size_t need; @@ -73,6 +73,7 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) if (switchon == 0 || (mybuf = typeMalloc(char, need + 1)) == 0) { + free(mybuf); errno = ENOMEM; return (ERR); } @@ -89,7 +90,7 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len) * data has actually been shipped to the terminal. If the write(2) * operation is truly atomic we're protected from this. */ - result = (int) write(TerminalOf(SP_PARM)->Filedes, mybuf, need); + result = (int) write(SP_PARM->_ofd, mybuf, need); /* * By giving up our scheduler slot here we increase the odds that the