summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/strfuncs.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/strfuncs.cc')
-rw-r--r--winsup/cygwin/strfuncs.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc
index 91ed160c3..9d0e3ec08 100644
--- a/winsup/cygwin/strfuncs.cc
+++ b/winsup/cygwin/strfuncs.cc
@@ -32,7 +32,10 @@ sys_wcstombs (char *tgt, int tlen, const WCHAR *src, int slen)
ret = WideCharToMultiByte (get_cp (), 0, src, slen, tgt, tlen, NULL, NULL);
if (ret)
- tgt[ret < tlen ? ret : tlen - 1] = '\0';
+ {
+ ret = (ret < tlen) ? ret : tlen - 1;
+ tgt[ret] = '\0';
+ }
return ret;
}