add missing \0 to the end of several strncpy strings
[rrdtool.git] / src / rrd_error.c
index a102b1f..68fcc8e 100644 (file)
@@ -80,6 +80,7 @@ rrd_set_error_r(struct rrd_context *rrd_ctx, char *fmt, ...)
     va_start(argp, fmt);
 #ifdef HAVE_VSNPRINTF
     vsnprintf((char *)rrd_ctx->rrd_error, rrd_ctx->len, fmt, argp);
+    rrd_ctx->rrd_error[rrd_ctx->len]='\0';
 #else
     vsprintf((char *)rrd_ctx->rrd_error, fmt, argp);
 #endif
@@ -110,7 +111,6 @@ rrd_new_context(void) {
        (struct rrd_context *) malloc(sizeof(struct rrd_context));
 
     if (rrd_ctx) {
-       rrd_ctx->len = 0;
        rrd_ctx->rrd_error = malloc(MAXLEN+10);
        rrd_ctx->lib_errstr = malloc(ERRBUFLEN+10);
        if (rrd_ctx->rrd_error && rrd_ctx->lib_errstr) {