summaryrefslogtreecommitdiff
path: root/libspectre
diff options
context:
space:
mode:
authorHib Eris <hib@hiberis.nl>2010-02-02 11:13:53 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2010-02-03 12:47:57 +0100
commita03d49102e2d83b1ee008296da426b67e5585302 (patch)
treee7f7d6de2ba894128d410e70fa9b64b715bd39bc /libspectre
parent5f261f571d1cd6bbd6dd12ca5eacb0edc79ebc06 (diff)
Use _vscprintf instead of vsnprintf when available
On Windows, if output was truncated, vsnprintf() does not return the number of characters which would have been written to the string if enough space had been available. To work around this, use _vcsprintf() instead.
Diffstat (limited to 'libspectre')
-rw-r--r--libspectre/spectre-utils.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libspectre/spectre-utils.c b/libspectre/spectre-utils.c
index 0d8cf02..d88bef9 100644
--- a/libspectre/spectre-utils.c
+++ b/libspectre/spectre-utils.c
@@ -162,11 +162,17 @@ spectre_strdup_vprintf (const char *format,
string = NULL;
#else /* !HAVE_VASPRINTF */
va_list args_copy;
+ int n;
char c;
SPECTRE_VA_COPY (args_copy, args);
- string = malloc ((vsnprintf (&c, 1, format, args) + 1) * sizeof (char));
+#if HAVE__VSCPRINTF
+ n = _vscprintf (format, args);
+#else
+ n = vsnprintf (&c, 1, format, args);
+#endif
+ string = malloc ((n + 1) * sizeof (char));
if (string) {
len = vsprintf (string, format, args_copy);
if (len < 0) {