Commit 0bf83788 authored by Simon McVittie's avatar Simon McVittie

g_strcompress: check that source is non-NULL rather than just crashing

Calling this function with a NULL argument is considered to be invalid,
but one of the regression tests does it anyway (to watch it crash), which
seems a good indication that it's expected to be somewhat common.
Let's check it rather than segfaulting.
Signed-off-by: Simon McVittie's avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113Reviewed-by: default avatarEmmanuele Bassi <ebassi@linux.intel.com>
Reviewed-by: Matthias Clasen's avatarMatthias Clasen <mclasen@redhat.com>
parent fbab468d
......@@ -1977,8 +1977,13 @@ gchar *
g_strcompress (const gchar *source)
{
const gchar *p = source, *octal;
gchar *dest = g_malloc (strlen (source) + 1);
gchar *q = dest;
gchar *dest;
gchar *q;
g_return_val_if_fail (source != NULL, NULL);
dest = g_malloc (strlen (source) + 1);
q = dest;
while (*p)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment