]> git.ozlabs.org Git - petitboot/commitdiff
lib/fold: Handle extra mbrtowc return case
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Thu, 20 Aug 2015 06:32:25 +0000 (16:32 +1000)
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Tue, 25 Aug 2015 03:29:48 +0000 (13:29 +1000)
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>
lib/fold/fold.c

index fd23b066f3e58b49c107176d5957c8eaae68b845..2566253aca8de697149d2c17477eb26ba14b455a 100644 (file)
@@ -36,8 +36,9 @@ void fold_text(const char *text,
 
                assert(bytes != (size_t)-1);
 
 
                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;
                }
                        line_cb(arg, start, end - start);
                        break;
                }