From c165c6a671f03a2e48549f247435d953710ce7dc Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 21 May 2019 18:13:53 +0200 Subject: [PATCH] libnm: don't assert against %NULL string in nm_utils_is_uuid() For a "is" check, it's inconvenient to assert against the parameter being %NULL. We should accept %NULL and just say that it's not a valid uuid. This relaxes previous API. --- libnm-core/nm-utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 5322a8d747..dc0b5b814e 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4713,11 +4713,14 @@ nm_utils_iface_valid_name (const char *name) /** * nm_utils_is_uuid: - * @str: a string that might be a UUID + * @str: (allow-none): a string that might be a UUID * * Checks if @str is a UUID * * Returns: %TRUE if @str is a UUID, %FALSE if not + * + * In older versions, nm_utils_is_uuid() did not accept %NULL as @str + * argument. Don't pass %NULL if you run against older versions of libnm. */ gboolean nm_utils_is_uuid (const char *str) @@ -4725,7 +4728,8 @@ nm_utils_is_uuid (const char *str) const char *p = str; int num_dashes = 0; - g_return_val_if_fail (str, FALSE); + if (!p) + return FALSE; while (*p) { if (*p == '-')