From 2b8852dececd0ff681e08fe2127d3defb4f73578 Mon Sep 17 00:00:00 2001 From: Michael Lentine Date: Fri, 31 Oct 2014 15:22:52 -0700 Subject: Fix native_handle_create to check if malloc fails Bug: 18076253 Change-Id: I8dbe3af88f52f18f74a3ab857fea53ae7585e2f7 --- libcutils/native_handle.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libcutils') diff --git a/libcutils/native_handle.c b/libcutils/native_handle.c index 4089968..9a4a5bb 100644 --- a/libcutils/native_handle.c +++ b/libcutils/native_handle.c @@ -30,9 +30,11 @@ native_handle_t* native_handle_create(int numFds, int numInts) native_handle_t* h = malloc( sizeof(native_handle_t) + sizeof(int)*(numFds+numInts)); - h->version = sizeof(native_handle_t); - h->numFds = numFds; - h->numInts = numInts; + if (h) { + h->version = sizeof(native_handle_t); + h->numFds = numFds; + h->numInts = numInts; + } return h; } -- cgit v1.1