]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: fix memleak because of ambiguous tags
authorRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 16 Mar 2016 12:18:19 +0000 (13:18 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Mar 2016 13:17:34 +0000 (14:17 +0100)
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 <ruediger.meier@ga-group.nl>
sys-utils/lscpu.c
tests/expected/lscpu/lscpu-x86_64-64cpu
tests/expected/lscpu/lscpu-x86_64-dell_e4310

index 3b338aac96f74fffd747244319fd53254b1ef36b..36e36c9ef2f56fb67fd6d8933da1ee888331aa86 100644 (file)
@@ -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 */
index 17350e377fc5940af52d5a549047dbc1f49fcae2..07990eadee5af67138f9ad2bc680029b6195f495 100644 (file)
@@ -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
index 929cdf94fa02129478b7cadcd9798d46c5b964ca..39ec32ca08a133106d469c36d5450f6cd58f5ae6 100644 (file)
@@ -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