X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fwrbuf.c;h=7015bade5050c23e39e065ad45f3a02450f86b12;hp=344e5742cc00e71ba8d6ad8a1deff7892e918724;hb=97fafedd350b74076d8a8e31e23102fa22d4b430;hpb=e529ed18a6825f980bb16b230e56c6d53743ced1 diff --git a/src/wrbuf.c b/src/wrbuf.c index 344e574..7015bad 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ @@ -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; }