vnc: avoid possible file handler leak
authorGonglei <arei.gonglei@huawei.com>
Wed, 11 Mar 2015 08:21:01 +0000 (16:21 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 12 Mar 2015 07:22:12 +0000 (08:22 +0100)
vs->lsock may equal to 0, modify the check condition,
avoid possible vs->lsock leak.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ui/vnc.c

index b514777c6eaf596a085b7cf996d0c40d08cf001d..1e95445c4a22c65e10a05a3abd3a5765050f0935 100644 (file)
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3644,7 +3644,7 @@ void vnc_display_open(const char *id, Error **errp)
             if (vs->ws_enabled) {
                 vs->lwebsock = inet_listen_opts(wsopts, 0, errp);
                 if (vs->lwebsock < 0) {
-                    if (vs->lsock) {
+                    if (vs->lsock != -1) {
                         close(vs->lsock);
                         vs->lsock = -1;
                     }