summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorRuediger Meier2017-06-27 20:33:18 +0200
committerRuediger Meier2017-06-29 14:04:18 +0200
commit81435af3be9de47fd74dff0c5e0a6add7c66ae9b (patch)
treeeb8d1997190d07201724088034d75b0233e9d9d6 /sys-utils/lscpu.c
parentlib/path: add error handling to path_vcreate() (diff)
downloadkernel-qcow2-util-linux-81435af3be9de47fd74dff0c5e0a6add7c66ae9b.tar.gz
kernel-qcow2-util-linux-81435af3be9de47fd74dff0c5e0a6add7c66ae9b.tar.xz
kernel-qcow2-util-linux-81435af3be9de47fd74dff0c5e0a6add7c66ae9b.zip
lsmem: fix, using freed memory
Simply avoiding strdup(). Error handling improved. This was the Clang Analyzer warning: Memory Error, Use-after-free sys-utils/lsmem.c:259:3: warning: Use of memory after it is freed err(EXIT_FAILURE, _("Failed to open %s"), path); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index f6e47277e..83f3a7d27 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1430,12 +1430,12 @@ read_nodes(struct lscpu_desc *desc)
int i = 0;
DIR *dir;
struct dirent *d;
- char *path;
+ const char *path;
/* number of NUMA node */
- path = path_strdup(_PATH_SYS_NODE);
+ if (!(path = path_get(_PATH_SYS_NODE)))
+ return;
dir = opendir(path);
- free(path);
while (dir && (d = readdir(dir))) {
if (is_node_dirent(d))