diff options
author | Thomas Haller <thaller@redhat.com> | 2021-05-06 21:39:30 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-05-11 13:56:49 +0200 |
commit | 853f411567fef300b184f1745bee19f38be5cdfa (patch) | |
tree | 61b2d7eb457397c00167412e6d89efcecaefd28f | |
parent | 2c628e4762aa6bd97304d3fcca66cc99dee62e34 (diff) | |
download | NetworkManager-853f411567fef300b184f1745bee19f38be5cdfa.tar.gz |
libnmt-newt: fix leak in nmt_newt_button_build_component()
Found by Coverity:
Error: RESOURCE_LEAK (CWE-772): [#def274] [important]
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:118: alloc_fn: Storage is returned from allocation function "g_strdup_printf".
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:118: var_assign: Assigning: "label" = storage returned from "g_strdup_printf(" <%s>", priv->label)".
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:119: noescape: Resource "label" is not freed or pointed-to in "nmt_newt_locale_from_utf8".
NetworkManager-1.31.3/src/libnmt-newt/nmt-newt-button.c:125: leaked_storage: Variable "label" going out of scope leaks the storage it points to.
# 123| }
# 124|
# 125|-> return co;
# 126| }
# 127|
Fixes: 3bda3fb60c10 ('nmtui: initial import of nmtui')
-rw-r--r-- | src/libnmt-newt/nmt-newt-button.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libnmt-newt/nmt-newt-button.c b/src/libnmt-newt/nmt-newt-button.c index 09ca1648a8..4518499b86 100644 --- a/src/libnmt-newt/nmt-newt-button.c +++ b/src/libnmt-newt/nmt-newt-button.c @@ -108,7 +108,8 @@ nmt_newt_button_build_component(NmtNewtComponent *component, gboolean sensitive) { NmtNewtButtonPrivate *priv = NMT_NEWT_BUTTON_GET_PRIVATE(component); newtComponent co; - char * label = NULL, *label_lc; + gs_free char * label = NULL; + char * label_lc; if (sensitive) { label_lc = nmt_newt_locale_from_utf8(priv->label); |