diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-27 20:55:28 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-27 20:55:28 +0000 |
commit | 03a134b6041e592a5b647372a29677cbeb0a86fc (patch) | |
tree | cad0dbf25e6ad59ee2e7077926809297fbaccfab | |
parent | 88e6132e8d91d11833d83234c6965fbda9db2a09 (diff) | |
download | mandoc-03a134b6041e592a5b647372a29677cbeb0a86fc.tar.gz |
Correctly set valsz this time.
-rw-r--r-- | roff.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 * |