From a85bfc1b81f5c7ca79e62bd7dab0c1f09a85a0f1 Mon Sep 17 00:00:00 2001 From: leitner Date: Tue, 25 Feb 2014 18:27:30 +0000 Subject: [PATCH] fmt_strn aborted one byte too late --- fmt/fmt_strn.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fmt/fmt_strn.c b/fmt/fmt_strn.c index b0cc0c4..2a58330 100644 --- a/fmt/fmt_strn.c +++ b/fmt/fmt_strn.c @@ -5,10 +5,10 @@ size_t fmt_strn(char *out,const char *in,size_t limit) { register const char* t=in; register const char* u=in+limit; for (;;) { - if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; - if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; - if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; - if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; + if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t; + if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t; + if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t; + if (!*t || t==u) break; if (s) { *s=*t; ++s; } ++t; } return t-in; }