X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_insnstr.c;h=ff1ae573a576d73b07efb3f7418db0b481aaccf8;hp=d147871037e98f0228ec635985ebcace7988e714;hb=dafd158641767f37aa900c195aaa77b27da38500;hpb=76a479337308b4b5e749fa8c38b7b7f482998c5b diff --git a/ncurses/base/lib_insnstr.c b/ncurses/base/lib_insnstr.c index d1478710..ff1ae573 100644 --- a/ncurses/base/lib_insnstr.c +++ b/ncurses/base/lib_insnstr.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2004-2009,2016 Free Software Foundation, Inc. * + * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2004-2009,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +41,7 @@ #include #include -MODULE_ID("$Id: lib_insnstr.c,v 1.5 2016/05/28 21:03:33 tom Exp $") +MODULE_ID("$Id: lib_insnstr.c,v 1.7 2020/02/02 23:34:34 tom Exp $") NCURSES_EXPORT(int) winsnstr(WINDOW *win, const char *s, int n) @@ -81,7 +82,7 @@ winsnstr(WINDOW *win, const char *s, int n) NCURSES_SIZE_T ox = win->_curx; const unsigned char *cp; - for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) { + for (cp = str; (n <= 0 || (cp - str) < n) && *cp; cp++) { _nc_insert_ch(sp, win, (chtype) UChar(*cp)); } win->_curx = ox;