xcbgrab: Free the host string after checking the connection
authorLuca Barbato <lu_zero@gentoo.org>
Thu, 5 Mar 2015 08:44:55 +0000 (09:44 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Sun, 8 Mar 2015 13:39:01 +0000 (14:39 +0100)
Prevent an use after free in the error message.

Bug-Id: CID 1274040
CC: libav-stable@libav.org
libavdevice/xcbgrab.c

index c4db983..20a29d1 100644 (file)
@@ -607,14 +607,17 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
 
     c->conn = xcb_connect(host, &screen_num);
 
-    if (opts)
-        av_free(host);
-
     if ((ret = xcb_connection_has_error(c->conn))) {
         av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
                s->filename[0] ? host : "default", ret);
+        if (opts)
+            av_freep(&host);
         return AVERROR(EIO);
     }
+
+    if (opts)
+        av_freep(&host);
+
     setup = xcb_get_setup(c->conn);
 
     c->screen = get_screen(setup, screen_num);