X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fwrbuf.c;h=7015bade5050c23e39e065ad45f3a02450f86b12;hp=972acffcc47680207e62b4a2da89387aca23d50b;hb=97fafedd350b74076d8a8e31e23102fa22d4b430;hpb=c00f4d99781f83c51fce80af10927023a4150331 diff --git a/src/wrbuf.c b/src/wrbuf.c index 972acff..7015bad 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -262,8 +263,9 @@ void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd) const char *wrbuf_cstr(WRBUF b) { - wrbuf_putc(b, '\0'); /* add '\0' */ - (b->pos)--; /* don't include '\0' in count */ + if (b->pos >= b->size) + wrbuf_grow(b, 1); + b->buf[b->pos] = '\0'; return b->buf; }