mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 10:40:08 +01:00
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:
parent
74a36168bb
commit
e4877b9ca2
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue