From d0b75b03bca36ed8a548655bba74297996cd69a6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 4 Sep 2018 13:12:34 +0200 Subject: lscpu: make xasprintf call more robust Signed-off-by: Karel Zak --- sys-utils/lscpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys-utils/lscpu.c') diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 122acca1a..57f097dae 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -837,7 +837,7 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod) desc->hypervisor = "PR/SM"; desc->virtype = VIRT_FULL; while (fgets(buf, sizeof(buf), fd) != NULL) { - char *str; + char *str, *p; if (!strstr(buf, "Control Program:")) continue; @@ -845,10 +845,10 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod) desc->hyper = HYPER_IBM; else desc->hyper = HYPER_KVM; - str = strchr(buf, ':'); - if (!str) + p = strchr(buf, ':'); + if (!p) continue; - xasprintf(&str, "%s", str + 1); + xasprintf(&str, "%s", p + 1); /* remove leading, trailing and repeating whitespace */ while (*str == ' ') -- cgit v1.2.3-55-g7522