aboutsummaryrefslogtreecommitdiff
path: root/ChangeLog
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-04-05 12:52:19 +0200
committerFangrui Song <i@maskray.me>2021-08-27 16:22:11 -0700
commitadb65ebdcda71510e1fd79cbeacecb6bfb36f6ae (patch)
treeaa057a1e93b4314a268b2314766e99f04877a2c0 /ChangeLog
parentd6df404c01fee9acfb7e0e08f0add4fd00e32a22 (diff)
downloadglibc-adb65ebdcda71510e1fd79cbeacecb6bfb36f6ae.zip
glibc-adb65ebdcda71510e1fd79cbeacecb6bfb36f6ae.tar.gz
glibc-adb65ebdcda71510e1fd79cbeacecb6bfb36f6ae.tar.bz2
manual: Various fixes to the mbstouwcs example, and mbrtowc update
The example did not work because the null byte was not converted, and mbrtowc was called with a zero-length input string. This results in a (size_t) -2 return value, so the function always returns NULL. The size computation for the heap allocation of the result was incorrect because it did not deal with integer overflow. Error checking was missing, and the allocated memory was not freed on error paths. All error returns now set errno. (Note that there is an assumption that free does not clobber errno.) The slightly unportable comparision against (size_t) -2 to catch both (size_t) -1 and (size_t) -2 return values is gone as well. A null wide character needs to be stored in the result explicitly, to terminate it. The description in the manual is updated to deal with these finer points. The (size_t) -2 behavior (consuming the input bytes) matches what is specified in ISO C11. (cherry picked from commit cf138b0c83b3210990b29772e2af5982fb0e3c26) (cherry picked from commit 690c3475f1417c99cb0fc69f35d77560c24c1d69)
Diffstat (limited to 'ChangeLog')
-rw-r--r--ChangeLog15
1 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index ef2816a..2775346 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2018-04-06 Andreas Schwab <schwab@linux-m68k.org>
+
+ * manual/charset.texi (Converting a Character): Fix typo.
+
+2018-04-05 Florian Weimer <fweimer@redhat.com>
+
+ * manual/examples/mbstouwcs.c (mbstouwcs): Fix loop termination,
+ integer overflow, memory leak on error, and indeterminate errno
+ value. Add a null wide character to terminate the result string.
+ * manual/charset.texi (Converting a Character): Mention embedded
+ null bytes in the mbrtowc input string. Explain what happens in
+ the -2 result case. Do not claim that mbrtowc is simple or
+ obvious to use. Adjust the description of the code example. Use
+ @code, not @var, for concrete variables.
+
2018-04-05 Florian Weimer <fweimer@redhat.com>
* manual/examples/mbstouwcs.c: New file.