ghostutils: Add a missing precondition check to g_hostname_to_unicode()

This helps out scan-build, which otherwise thinks there could be a
`NULL` pointer dereference.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #1767
This commit is contained in:
Philip Withnall 2024-04-12 17:40:21 +01:00
parent 057f0fcbfb
commit cf940496df
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -32,6 +32,7 @@
#include "garray.h"
#include "gmem.h"
#include "gmessages.h"
#include "gstring.h"
#include "gstrfuncs.h"
#include "glibintl.h"
@ -667,6 +668,8 @@ g_hostname_to_unicode (const gchar *hostname)
gssize llen;
gsize hostname_max_length_bytes = get_hostname_max_length_bytes ();
g_return_val_if_fail (hostname != NULL, NULL);
/* See the comment at the top of g_hostname_to_ascii(). */
if (hostname_max_length_bytes <= G_MAXSIZE / 4 &&
strlen_greater_than (hostname, 4 * MAX (255, hostname_max_length_bytes)))