From: oetiker Date: Tue, 27 May 2008 22:24:32 +0000 (+0000) Subject: fixed maxlength for sprintf_alloc 50 was not enough ... 1024+strlen(fmt) is much... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6dd3bc23a99b761cd3e40a357b70e027d2cd0de3;p=rrdtool-all.git 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@1385 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_info.c b/program/src/rrd_info.c index cf90e0e2..a48df516 100644 --- a/program/src/rrd_info.c +++ b/program/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