summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-26 12:29:23 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-26 12:29:23 +0000
commit39271cfe09f3e395cebb5b577f2fe687ec4d59d2 (patch)
treeb906a81b4c89ea7eab5db3d15824e10ef88998e9
parent9759ef3b695c612f285923467b3f3bcbd7c9fbec (diff)
downloadcrawl-ref-39271cfe09f3e395cebb5b577f2fe687ec4d59d2.tar.gz
crawl-ref-39271cfe09f3e395cebb5b577f2fe687ec4d59d2.zip
Fixed Crawl's home-rolled snprintf for -pedantic.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@140 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/libutil.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index 2e256b03cc..e03ddc1e78 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -400,7 +400,12 @@ int snprintf( char *str, size_t size, const char *format, ... )
va_list argp;
va_start( argp, format );
- char buff[ 10 * size ]; // hopefully enough
+ char *buff = new char [ 10 * size ]; // hopefully enough
+ if (!buff)
+ {
+ fprintf(stderr, "Out of memory\n");
+ exit(1);
+ }
vsprintf( buff, format, argp );
strncpy( str, buff, size );
@@ -410,6 +415,8 @@ int snprintf( char *str, size_t size, const char *format, ... )
if ((unsigned int) ret == size - 1 && strlen( buff ) >= size)
ret = -1;
+ delete [] buff;
+
va_end( argp );
return (ret);