提交 f454f49c 编写于 作者: G Gonglei 提交者: Gerd Hoffmann

egl-helpers: fix possible resource leak

CID 1352419, using g_strdup_printf instead of asprintf.
Signed-off-by: NGonglei <arei.gonglei@huawei.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Message-id: 1463047028-123868-2-git-send-email-arei.gonglei@huawei.com
Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
上级 42ddb8aa
...@@ -49,18 +49,15 @@ int qemu_egl_rendernode_open(void) ...@@ -49,18 +49,15 @@ int qemu_egl_rendernode_open(void)
continue; continue;
} }
r = asprintf(&p, "/dev/dri/%s", e->d_name); p = g_strdup_printf("/dev/dri/%s", e->d_name);
if (r < 0) {
return -1;
}
r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK); r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (r < 0) { if (r < 0) {
free(p); g_free(p);
continue; continue;
} }
fd = r; fd = r;
free(p); g_free(p);
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册