teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
Blob Blame History Raw
From a72c398b5af558d231decbbf12c7990dbd38c682 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 10 Oct 2013 13:09:37 +0200
Subject: [PATCH] login: fix invalid free() in sd_session_get_vt()

We need to clear variables markes as _cleanup_free_. Otherwise, our
error-paths might corrupt random memory.
---
 src/login/sd-login.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index 71d8c29..6c27dfe 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -350,7 +350,7 @@ _public_ int sd_session_get_tty(const char *session, char **tty) {
 }
 
 _public_ int sd_session_get_vt(const char *session, unsigned *vtnr) {
-        _cleanup_free_ char *vtnr_string;
+        _cleanup_free_ char *vtnr_string = NULL;
         unsigned u;
         int r;