From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFIft-0000qX-Of for qemu-devel@nongnu.org; Thu, 07 Aug 2014 04:03:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFIfo-0004wR-VE for qemu-devel@nongnu.org; Thu, 07 Aug 2014 04:03:49 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:5700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFIfo-0004vv-7u for qemu-devel@nongnu.org; Thu, 07 Aug 2014 04:03:44 -0400 From: zhanghailiang Date: Thu, 7 Aug 2014 16:01:47 +0800 Message-ID: <1407398512-20780-6-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1407398512-20780-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1407398512-20780-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v3 05/10] util/path: check return value of malloc() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, lkurusa@redhat.com, zhanghailiang , mst@redhat.com, jan.kiszka@siemens.com, riku.voipio@iki.fi, mjt@tls.msk.ru, peter.huangpeng@huawei.com, lcapitulino@redhat.com, stefanha@redhat.com, luonengjun@huawei.com, pbonzini@redhat.com, alex.bennee@linaro.org, rth@twiddle.net Signed-off-by: zhanghailiang --- util/path.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/path.c b/util/path.c index 5c59d9f..df1653f 100644 --- a/util/path.c +++ b/util/path.c @@ -46,9 +46,12 @@ static struct pathelem *new_entry(const char *root, const char *name) { struct pathelem *new = malloc(sizeof(*new)); - new->name = strdup(name); - new->pathname = g_strdup_printf("%s/%s", root, name); - new->num_entries = 0; + + if (new) { + new->name = strdup(name); + new->pathname = g_strdup_printf("%s/%s", root, name); + new->num_entries = 0; + } return new; } -- 1.7.12.4