diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2022-10-20 12:29:11 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2022-10-20 12:29:11 +0000 |
commit | 4dcb7f1f9f773452686b67a605635d832bed57e0 (patch) | |
tree | 46a8044055c7963f3a65b48080c2b2704290e782 | |
parent | e49c4b1a9efdce1536dd231290d3ec5926478696 (diff) | |
parent | b204b46fc0c1a36b327eb5979a5ae6297dc5d049 (diff) | |
download | glib-4dcb7f1f9f773452686b67a605635d832bed57e0.tar.gz |
Merge branch '2753-vasprintf-loop' into 'main'
gprintf: Avoid an infinite loop on ENOMEM in g_vasprintf()
Closes #2753
See merge request GNOME/glib!2944
-rw-r--r-- | glib/gprintf.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/glib/gprintf.c b/glib/gprintf.c index 818a55ad2..10b436533 100644 --- a/glib/gprintf.c +++ b/glib/gprintf.c @@ -342,7 +342,14 @@ g_vasprintf (gchar **string, if (len < 0) { if (saved_errno == ENOMEM) - g_error ("%s: failed to allocate memory", G_STRLOC); + { + /* Try and print a message to be a bit helpful, but stick to the + * bare minimum to avoid any code path which could try and fail to + * allocate additional memory. */ + fputs (G_STRLOC, stderr); + fputs (": failed to allocate memory\n", stderr); + g_abort (); + } else *string = NULL; } |