mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
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:
parent
057f0fcbfb
commit
cf940496df
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "garray.h"
|
#include "garray.h"
|
||||||
#include "gmem.h"
|
#include "gmem.h"
|
||||||
|
#include "gmessages.h"
|
||||||
#include "gstring.h"
|
#include "gstring.h"
|
||||||
#include "gstrfuncs.h"
|
#include "gstrfuncs.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
@ -667,6 +668,8 @@ g_hostname_to_unicode (const gchar *hostname)
|
|||||||
gssize llen;
|
gssize llen;
|
||||||
gsize hostname_max_length_bytes = get_hostname_max_length_bytes ();
|
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(). */
|
/* See the comment at the top of g_hostname_to_ascii(). */
|
||||||
if (hostname_max_length_bytes <= G_MAXSIZE / 4 &&
|
if (hostname_max_length_bytes <= G_MAXSIZE / 4 &&
|
||||||
strlen_greater_than (hostname, 4 * MAX (255, hostname_max_length_bytes)))
|
strlen_greater_than (hostname, 4 * MAX (255, hostname_max_length_bytes)))
|
||||||
|
Loading…
Reference in New Issue
Block a user