X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffold%2Ffold.c;h=812a324839223df6fd43af74f5549754fb6a0146;hb=ff7293bba1fd4cdf54bb90bd1b7a38dd393fee69;hp=fd23b066f3e58b49c107176d5957c8eaae68b845;hpb=d28e414354d791a8c010cf6069bfc549d4343811;p=petitboot diff --git a/lib/fold/fold.c b/lib/fold/fold.c index fd23b06..812a324 100644 --- a/lib/fold/fold.c +++ b/lib/fold/fold.c @@ -36,8 +36,10 @@ 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, (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; }