X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fwidechar%2Flib_unget_wch.c;h=4ea26b6034b55d621ef3db481d18da847ace0f0c;hp=6a2346d570a3d1848bd7585956ddfd03b53e3708;hb=HEAD;hpb=76a479337308b4b5e749fa8c38b7b7f482998c5b diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c index 6a2346d5..1a81fecc 100644 --- a/ncurses/widechar/lib_unget_wch.c +++ b/ncurses/widechar/lib_unget_wch.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2002-2011,2016 Free Software Foundation, Inc. * + * Copyright 2020,2023 Thomas E. Dickey * + * Copyright 2002-2011,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 * @@ -39,7 +40,7 @@ #include -MODULE_ID("$Id: lib_unget_wch.c,v 1.16 2016/05/28 23:36:34 tom Exp $") +MODULE_ID("$Id: lib_unget_wch.c,v 1.18 2023/06/03 12:50:52 tom Exp $") /* * Wrapper for wcrtomb() which obtains the length needed for the given @@ -59,7 +60,7 @@ _nc_wcrtomb(char *target, wchar_t source, mbstate_t * state) } else { result = (int) wcrtomb(target, source, state); } - if (!isEILSEQ(result) && (result == 0)) + if (!isEILSEQ(result) && ((result == 0) || (result > MB_LEN_MAX))) result = 1; return (size_t) result; }