Fix length returned from sys_cp_wcstombs in case nwc > # of wchars

* strfuncs.cc (sys_cp_wcstombs): Always return number of multibytes
	without trailing NUL as the documentation implies.  Throughout Cygwin,
	fix usage to align to this pattern.
	* fhandler_process.cc (format_process_winexename): Drop trailing NUL
	and LF from output.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2015-10-22 14:22:07 +02:00
parent c0345822e5
commit ef75017378
9 changed files with 23 additions and 14 deletions

View File

@@ -568,9 +568,9 @@ format_process_winexename (void *data, char *&destbuf)
_pinfo *p = (_pinfo *) data;
size_t len = sys_wcstombs (NULL, 0, p->progname);
destbuf = (char *) crealloc_abort (destbuf, len + 1);
sys_wcstombs (destbuf, len, p->progname);
destbuf[len] = '\n';
return len + 1;
/* With trailing \0 for backward compat reasons. */
sys_wcstombs (destbuf, len + 1, p->progname);
return len;
}
struct heap_info