From 3dfc77dfc12f2cf4cf8b2bff88b6dbed2b0b5c8d Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 7 Aug 2012 14:22:28 +0200 Subject: [PATCH] nfctype2: Fix possible NULL pointer dereference in data_write Check if memory allocation succeed before dereferencing pointer. --- plugins/nfctype2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/nfctype2.c b/plugins/nfctype2.c index 4a9405d..50ae94f 100644 --- a/plugins/nfctype2.c +++ b/plugins/nfctype2.c @@ -390,6 +390,9 @@ static int data_write(uint32_t adapter_idx, uint32_t target_idx, DBG(""); cookie = g_try_malloc0(sizeof(struct t2_cookie)); + if (cookie == NULL) + return -ENOMEM; + cookie->adapter_idx = adapter_idx; cookie->target_idx = target_idx; cookie->current_block = DATA_BLOCK_START; -- 2.7.4