From 596c0de84c5a8a499213ec024d61c49876b11167 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 27 Jul 2011 20:55:28 +0000 Subject: Correctly set valsz this time. --- roff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'roff.c') diff --git a/roff.c b/roff.c index b2332224..646f3caa 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.162 2011/07/27 17:25:30 kristaps Exp $ */ +/* $Id: roff.c,v 1.163 2011/07/27 20:55:28 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -1497,12 +1497,10 @@ roff_setstr(struct roff *r, const char *name, const char *string, if (NULL == n->val) { n->val = mandoc_malloc(newch); *n->val = '\0'; - n->valsz = newch - 1; oldch = 0; } else { oldch = n->valsz; - n->val = mandoc_realloc(n->val, n->valsz + newch); - n->valsz += newch - 1; + n->val = mandoc_realloc(n->val, oldch + newch); } /* Skip existing content in the destination buffer. */ @@ -1522,7 +1520,9 @@ roff_setstr(struct roff *r, const char *name, const char *string, /* Append terminating bytes. */ if (multiline) *c++ = '\n'; + *c = '\0'; + n->valsz = (int)(c - n->val); } static const char * -- cgit v1.2.3