Skip to content

Commit

Permalink
networkd: plug a memory leak
Browse files Browse the repository at this point in the history
Use g_autoptr() with GStrings link and network. Found by Coverity.
  • Loading branch information
daniloegea committed Jul 19, 2023
1 parent 6517885 commit a771f0e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/networkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,8 @@ netplan_netdef_write_network_file(
gboolean* has_been_written,
GError** error)
{
GString* network = NULL;
GString* link = NULL;
g_autoptr(GString) network = NULL;
g_autoptr(GString) link = NULL;
GString* s = NULL;
mode_t orig_umask;
gboolean is_optional = def->optional;
Expand Down Expand Up @@ -963,9 +963,6 @@ netplan_netdef_write_network_file(
if (network->len > 0)
g_string_append_printf(s, "\n[Network]\n%s", network->str);

g_string_free(link, TRUE);
g_string_free(network, TRUE);

/* these do not contain secrets and need to be readable by
* systemd-networkd - LP: #1736965 */
orig_umask = umask(022);
Expand Down

0 comments on commit a771f0e

Please sign in to comment.