shared: make nm_utils_strdup_reset() self-assignment safe

There is no need to write code that has such trivial flaws.

  val = g_strdup ("aaaa");
  nm_utils_strdup_reset (&val, &val[1]);
This commit is contained in:
Thomas Haller 2020-07-19 11:31:14 +02:00
parent 74a36168bb
commit e4877b9ca2
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1980,12 +1980,15 @@ guint nm_utils_parse_debug_string (const char *string,
static inline gboolean
nm_utils_strdup_reset (char **dst, const char *src)
{
char *old;
nm_assert (dst);
if (nm_streq0 (*dst, src))
return FALSE;
g_free (*dst);
old = *dst;
*dst = g_strdup (src);
g_free (old);
return TRUE;
}