From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFgO3-00016F-F1 for qemu-devel@nongnu.org; Fri, 08 Aug 2014 05:23:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFgNw-0004sG-2x for qemu-devel@nongnu.org; Fri, 08 Aug 2014 05:22:59 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:45181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFgNv-0004rf-9x for qemu-devel@nongnu.org; Fri, 08 Aug 2014 05:22:52 -0400 From: zhanghailiang Date: Fri, 8 Aug 2014 17:21:07 +0800 Message-ID: <1407489672-12212-6-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1407489672-12212-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1407489672-12212-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v4 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 Reviewed-by: Gonglei 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