From f9bc1d0850c92394c8dd3f8d05691e71811baf95 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 19 Apr 2014 11:17:22 +0200 Subject: [PATCH 1/1] wrbuf_buf: make it always return non-NULL Also, wrbuf_buf will return same buffer as previous call to wrbuf_cstr. --- src/wrbuf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wrbuf.c b/src/wrbuf.c index fa42894..6d9b145 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -31,6 +31,7 @@ WRBUF wrbuf_alloc(void) n->buf = 0; n->size = 0; n->pos = 0; + wrbuf_grow(n, 1); return n; } @@ -262,9 +263,7 @@ void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd) const char *wrbuf_cstr(WRBUF b) { - if (b->pos == 0) - return ""; - assert(b->pos <= b->size); + assert(b && b->pos <= b->size); b->buf[b->pos] = '\0'; return b->buf; } -- 1.7.10.4