From: Ruediger Meier Date: Wed, 16 Mar 2016 12:18:19 +0000 (+0100) Subject: lscpu: fix memleak because of ambiguous tags X-Git-Tag: v2.28-rc2~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5fc6d6fb57c1fb22b6dcff584639ade37ad8b9b;p=thirdparty%2Futil-linux.git lscpu: fix memleak because of ambiguous tags Now the first one of certain ambiguous tags wins. Alternatively to this patch we could have called free() before xstrdup(). Signed-off-by: Ruediger Meier --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 3b338aac96..36e36c9ef2 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -353,7 +353,8 @@ lookup(char *line, char *pattern, char **value) char *p, *v; int len = strlen(pattern); - if (!*line) + /* don't re-fill already found tags, first one wins */ + if (!*line || *value) return 0; /* pattern */ diff --git a/tests/expected/lscpu/lscpu-x86_64-64cpu b/tests/expected/lscpu/lscpu-x86_64-64cpu index 17350e377f..07990eadee 100644 --- a/tests/expected/lscpu/lscpu-x86_64-64cpu +++ b/tests/expected/lscpu/lscpu-x86_64-64cpu @@ -13,7 +13,7 @@ Stepping: 6 CPU MHz: 1064.000 CPU max MHz: 1996.0000 CPU min MHz: 1064.0000 -BogoMIPS: 3989.44 +BogoMIPS: 3990.31 Virtualization: VT-x L1d cache: 32K L1i cache: 32K diff --git a/tests/expected/lscpu/lscpu-x86_64-dell_e4310 b/tests/expected/lscpu/lscpu-x86_64-dell_e4310 index 929cdf94fa..39ec32ca08 100644 --- a/tests/expected/lscpu/lscpu-x86_64-dell_e4310 +++ b/tests/expected/lscpu/lscpu-x86_64-dell_e4310 @@ -13,7 +13,7 @@ Stepping: 5 CPU MHz: 1199.000 CPU max MHz: 2667.0000 CPU min MHz: 1199.0000 -BogoMIPS: 5319.97 +BogoMIPS: 5319.92 Virtualization: VT-x L1d cache: 32K L1i cache: 32K