X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fwidechar%2Flib_unget_wch.c;h=1a81fecc87058012335de5e9a6547d5b5e91692f;hp=4ea26b6034b55d621ef3db481d18da847ace0f0c;hb=HEAD;hpb=47d2fb4537d9ad5bb14f4810561a327930ca4280 diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c index 4ea26b60..1a81fecc 100644 --- a/ncurses/widechar/lib_unget_wch.c +++ b/ncurses/widechar/lib_unget_wch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * 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 * @@ -40,7 +40,7 @@ #include -MODULE_ID("$Id: lib_unget_wch.c,v 1.17 2020/02/02 23:34: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 @@ -60,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; }