The variable 's' is still in scope until we exit the function. We
can't call read_one_line_file on it multiple times without calling
free in between.
---
 src/basic/virt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/basic/virt.c b/src/basic/virt.c
index 1e10fc755f201..f88bd04bd72ed 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -176,9 +176,10 @@ static int detect_vm_dmi(void) {
 
                 r = read_one_line_file(dmi_vendors[i], &s);
                 if (r < 0) {
-                        if (r == -ENOENT)
+                        if (r == -ENOENT) {
+                                free(s);
                                 continue;
-
+                        }
                         return r;
                 }
 
-- 
2.4.3

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to