diff options
Diffstat (limited to 'glib/gprintf.c')
-rw-r--r-- | glib/gprintf.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/glib/gprintf.c b/glib/gprintf.c index fc0a02a3b..d4d0b3e0c 100644 --- a/glib/gprintf.c +++ b/glib/gprintf.c @@ -20,6 +20,7 @@ #include <stdarg.h> #include <stdlib.h> #include <stdio.h> +#include <errno.h> #include "gprintf.h" #include "gprintfint.h" @@ -327,9 +328,18 @@ g_vasprintf (gchar **string, #elif defined (HAVE_VASPRINTF) - len = vasprintf (string, format, args); - if (len < 0) - *string = NULL; + { + int saved_errno; + len = vasprintf (string, format, args); + saved_errno = errno; + if (len < 0) + { + if (saved_errno == ENOMEM) + g_error ("%s: failed to allocate memory", G_STRLOC); + else + *string = NULL; + } + } #else |