From 3864a4538872269d9bdbeda5cb88bee80f2a07cc Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Wed, 28 May 2014 19:03:07 +0000 Subject: Fixed NULL terminated string. --- src/htstools.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/htstools.c') diff --git a/src/htstools.c b/src/htstools.c index dc538ef..0894e47 100644 --- a/src/htstools.c +++ b/src/htstools.c @@ -772,6 +772,7 @@ static int hts_template_formatv(hts_template_format_buf *buf, #undef FPUTS #define FPUTC(C) do { \ if (buf->fp != NULL) { \ + assertf(buf->buffer == NULL); \ if (fputc(C, buf->fp) < 0) { \ return -1; \ } \ @@ -828,6 +829,10 @@ static int hts_template_formatv(hts_template_format_buf *buf, FPUTC(c); } } + /* Terminating NULL. */ + if (buf->buffer != NULL) { + buf->buffer[buf->offset] = 0; + } return 1; } else { return -1; -- cgit v1.2.3