diff options
author | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-08-20 16:32:25 +1000 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-08-25 13:29:48 +1000 |
commit | 9818a3cd88578ffadb4ff3f5562e468e3b4b6f95 (patch) | |
tree | e248fcb1a3813313516f9e11e633f047e548358e /lib/fold | |
parent | 1305a464f085200aa9adc77bcacfb1c771258c82 (diff) | |
download | talos-petitboot-9818a3cd88578ffadb4ff3f5562e468e3b4b6f95.tar.gz talos-petitboot-9818a3cd88578ffadb4ff3f5562e468e3b4b6f95.zip |
lib/fold: Handle extra mbrtowc return case
Commit 9781a370 ("Handle mblen return code when n is zero.") in glibc
changes the return value for when the number of bytes ('n') is zero.
Add an extra condition to detect if we've reached the end of the buffer.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'lib/fold')
-rw-r--r-- | lib/fold/fold.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/fold/fold.c b/lib/fold/fold.c index fd23b06..2566253 100644 --- a/lib/fold/fold.c +++ b/lib/fold/fold.c @@ -36,8 +36,9 @@ void fold_text(const char *text, assert(bytes != (size_t)-1); - /* we'll get a zero size for the nul terminator */ - if (!bytes) { + /* we'll get a zero size for the nul terminator, or (size_t) -2 + * if we've reached the end of the buffer */ + if (!bytes || bytes == (size_t) -2) { line_cb(arg, start, end - start); break; } |