From e8c71854ca1387f5db46e01035733e1eb5202050 Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 27 May 2008 22:24:32 +0000 Subject: [PATCH] fixed maxlength for sprintf_alloc 50 was not enough ... 1024+strlen(fmt) is much better. This makes imginfo work even when there are long image paths. git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1385 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_info.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/rrd_info.c b/src/rrd_info.c index cf90e0e..a48df51 100644 --- a/src/rrd_info.c +++ b/src/rrd_info.c @@ -20,18 +20,14 @@ char *sprintf_alloc( char *fmt, ...) { -#ifdef HAVE_VSNPRINTF - int maxlen = 50; -#else - int maxlen = 1000; -#endif + int maxlen = 1024 + strlen(fmt); char *str = NULL; va_list argp; - str = malloc(sizeof(char) * (strlen(fmt) + maxlen)); + str = malloc(sizeof(char) * (maxlen+1)); if (str != NULL) { va_start(argp, fmt); #ifdef HAVE_VSNPRINTF - vsnprintf(str, maxlen - 1, fmt, argp); + vsnprintf(str, maxlen, fmt, argp); #else vsprintf(str, fmt, argp); #endif -- 2.11.0