From 638d8af4e978c7c7306529457cd2084c75c8ff83 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 2 Dec 2015 07:43:18 +1100 Subject: [PATCH] text: fix bug with adding at end of allocation. Signed-off-by: NeilBrown --- doc-text.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc-text.c b/doc-text.c index 2b8550ec..930b22d4 100644 --- a/doc-text.c +++ b/doc-text.c @@ -353,15 +353,18 @@ static void text_add_str(struct text *t, struct doc_ref *pos, char *str, */ struct text_alloc *a = t->alloc; int len = strlen(str); + int len2; if (start) *start = *pos; + len2 = len; if (pos->c && pos->o == pos->c->end && pos->c->txt + pos->o == a->text + a->free && (a->size - a->free >= len || - (len = text_round_len(str, a->size - a->free)) > 0)) { + (len2 = text_round_len(str, a->size - a->free)) > 0)) { /* Some of this ('len') can be added to the current chunk */ + len = len2; memcpy(a->text+a->free, str, len); a->free += len; pos->c->end += len; -- 2.39.5