summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-27 20:55:28 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-27 20:55:28 +0000
commit03a134b6041e592a5b647372a29677cbeb0a86fc (patch)
treecad0dbf25e6ad59ee2e7077926809297fbaccfab
parent88e6132e8d91d11833d83234c6965fbda9db2a09 (diff)
downloadmandoc-03a134b6041e592a5b647372a29677cbeb0a86fc.tar.gz
Correctly set valsz this time.
-rw-r--r--roff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/roff.c b/roff.c
index d7672a55..08fa0153 100644
--- a/roff.c
+++ b/roff.c
@@ -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 *