From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CHG-0005BM-Cp for qemu-devel@nongnu.org; Fri, 13 May 2016 08:33:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b1CH9-0006kQ-3T for qemu-devel@nongnu.org; Fri, 13 May 2016 08:33:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b1CH8-0006jZ-Uf for qemu-devel@nongnu.org; Fri, 13 May 2016 08:33:03 -0400 From: Gerd Hoffmann Date: Fri, 13 May 2016 14:32:54 +0200 Message-Id: <1463142777-13040-15-git-send-email-kraxel@redhat.com> In-Reply-To: <1463142777-13040-1-git-send-email-kraxel@redhat.com> References: <1463142777-13040-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL v2 14/17] egl-helpers: fix possible resource leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei , Gerd Hoffmann From: Gonglei CID 1352419, using g_strdup_printf instead of asprintf. Signed-off-by: Gonglei Reviewed-by: Paolo Bonzini Message-id: 1463047028-123868-2-git-send-email-arei.gonglei@huawei.com Signed-off-by: Gerd Hoffmann --- ui/egl-helpers.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 558edfd..22835c0 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -49,18 +49,15 @@ int qemu_egl_rendernode_open(void) continue; } - r = asprintf(&p, "/dev/dri/%s", e->d_name); - if (r < 0) { - return -1; - } + p = g_strdup_printf("/dev/dri/%s", e->d_name); r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK); if (r < 0) { - free(p); + g_free(p); continue; } fd = r; - free(p); + g_free(p); break; } -- 1.8.3.1