From d0d962d3d1a4aa4ac4f9324fe99100f32ad65871 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 30 Oct 2017 16:35:01 +0100 Subject: [PATCH] ifcfg: fix invalid free in parse_route_line() Cannot free NM_PTRARRAY_EMPTY(). Discovered by coverity. Fixes: 6d675a943b99d0ed5ff9c8360dcc485174a41401 --- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index af317550b4..87d97173dc 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -589,7 +589,8 @@ parse_route_line (const char *line, GError **error) { nm_auto_ip_route_unref NMIPRoute *route = NULL; - gs_free const char **words = NULL; + gs_free const char **words_free = NULL; + const char *const*words; const char *s; gsize i_words; guint i; @@ -653,10 +654,9 @@ parse_route_line (const char *line, * Maybe later we want to support some form of quotation here. * Which of course, would be incompatible with initscripts. */ - words = nm_utils_strsplit_set (line, " \t\n"); + words_free = nm_utils_strsplit_set (line, " \t\n"); - if (!words) - words = (const char **) NM_PTRARRAY_EMPTY (const char *); + words = words_free ?: NM_PTRARRAY_EMPTY (const char *); for (i_words = 0; words[i_words]; ) { const gsize i_words0 = i_words;