]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/widechar/lib_unget_wch.c
ncurses 6.4 - patch 20240420
[ncurses.git] / ncurses / widechar / lib_unget_wch.c
index 6a2346d570a3d1848bd7585956ddfd03b53e3708..1a81fecc87058012335de5e9a6547d5b5e91692f 100644 (file)
@@ -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 <curses.priv.h>
 
-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;
 }