summaryrefslogtreecommitdiffstatshomepage
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
commit596c0de84c5a8a499213ec024d61c49876b11167 (patch)
tree3a1a587f166a576f47bce4223080da5b7ad98a87
parent08971ae0d318ca4384957d962d049ba2a3a3f8a7 (diff)
downloadmandoc-596c0de84c5a8a499213ec024d61c49876b11167.tar.gz
mandoc-596c0de84c5a8a499213ec024d61c49876b11167.tar.zst
mandoc-596c0de84c5a8a499213ec024d61c49876b11167.zip
Correctly set valsz this time.
-rw-r--r--roff.c8
1 files changed, 4 insertions, 4 deletions
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 <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 *