mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Fix bug in strbuf_ncat(): not appending nul terminator
This commit is contained in:
parent
0022990e72
commit
355af1f874
3
strbuf.c
3
strbuf.c
@ -46,8 +46,9 @@ strbuf strbuf_ncat(strbuf sb, const char *text, size_t len)
|
||||
if (sb->start && sb->current < sb->end) {
|
||||
register size_t n = min(sb->end - sb->current, len);
|
||||
char *c;
|
||||
for (c = sb->current; n-- && (*c = *text); ++c, ++text)
|
||||
for (c = sb->current; n && (*c = *text); --n, ++c, ++text)
|
||||
;
|
||||
*c = '\0';
|
||||
}
|
||||
sb->current += len;
|
||||
return sb;
|
||||
|
Loading…
Reference in New Issue
Block a user