X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Ffold%2Ffold.c;h=812a324839223df6fd43af74f5549754fb6a0146;hp=8bf133c8b34a9e0e37762eda8122dce4ac210141;hb=5c3c324cc42f179fb41ca825fbce06bc445c730b;hpb=3aef1b6d1f465596ebf7883a50efcf4d6f0ffcf4;ds=sidebyside diff --git a/lib/fold/fold.c b/lib/fold/fold.c index 8bf133c..812a324 100644 --- a/lib/fold/fold.c +++ b/lib/fold/fold.c @@ -34,10 +34,12 @@ void fold_text(const char *text, bytes = mbrtowc(&wc, end, len - (end - text), &ps); - assert(bytes >= 0); + 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, (size_t) -2 + * if we've reached the end of the buffer, or (size_t) -1 on + * error */ + if (!bytes || bytes == (size_t) -2 || bytes == (size_t) -1) { line_cb(arg, start, end - start); break; }