[virt-tools-list] [virt-viewer PATCH 4/5] Declare VirtViewerFile variable at start of method

Daniel P. Berrangé berrange at redhat.com
Wed Feb 13 17:04:40 UTC 2019


virt_viewer_session_vnc_auth_credential uses gotos which jump over the
declaration of 'file', meaning its contents are uninitialized in the
jump target.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/virt-viewer-session-vnc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index e7c8cad..31d5361 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -273,6 +273,7 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED,
     VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
     char *username = NULL, *password = NULL;
     gboolean wantPassword = FALSE, wantUsername = FALSE;
+    VirtViewerFile *file = NULL;
     int i;
 
     g_debug("Got VNC credential request for %u credential(s)", credList->n_values);
@@ -295,7 +296,7 @@ virt_viewer_session_vnc_auth_credential(GtkWidget *src G_GNUC_UNUSED,
         }
     }
 
-    VirtViewerFile *file = virt_viewer_session_get_file(VIRT_VIEWER_SESSION(self));
+    file = virt_viewer_session_get_file(VIRT_VIEWER_SESSION(self));
     if (file != NULL) {
         if (wantUsername) {
             if (virt_viewer_file_is_set(file, "username")) {
-- 
2.20.1




More information about the virt-tools-list mailing list