summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2016-05-11 17:34:55 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-05-11 17:34:55 +0000
commit521bca9ceda94da2d15d82ceb12830c7b5019030 (patch)
treea94c0474b20935bba5eea24204cf82c0e1cc0f16
parent6b4cc13b56f7e319ed2a613ac9c3df0f37ba133a (diff)
parentce0c63a05ff779753b54b23a09ac6724d64cab71 (diff)
downloadlibnfc-nci-521bca9ceda94da2d15d82ceb12830c7b5019030.tar.gz
Merge "Free memory in case of error response" am: 3a6393f85f
am: ce0c63a05f * commit 'ce0c63a05ff779753b54b23a09ac6724d64cab71': Free memory in case of error response Change-Id: I2e2ef6f956789cd62e72a9ce7799ccfcd0cdb31c
-rw-r--r--src/nfc/tags/rw_t1t.c16
-rw-r--r--src/nfc/tags/rw_t2t.c18
-rw-r--r--src/nfc/tags/rw_t3t.c6
3 files changed, 31 insertions, 9 deletions
diff --git a/src/nfc/tags/rw_t1t.c b/src/nfc/tags/rw_t1t.c
index e7d373e..1fd074e 100644
--- a/src/nfc/tags/rw_t1t.c
+++ b/src/nfc/tags/rw_t1t.c
@@ -254,11 +254,19 @@ void rw_t1t_conn_cback (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data)
break;
case NFC_DATA_CEVT:
- if ( (p_data != NULL)
- &&(p_data->data.status == NFC_STATUS_OK) )
+ if (p_data != NULL)
{
- rw_t1t_data_cback (conn_id, event, p_data);
- break;
+ if (p_data->data.status == NFC_STATUS_OK)
+ {
+ rw_t1t_data_cback (conn_id, event, p_data);
+ break;
+ }
+ else if (p_data->data.p_data != NULL)
+ {
+ /* Free the response buffer in case of error response */
+ GKI_freebuf ((BT_HDR *) (p_data->data.p_data));
+ p_data->data.p_data = NULL;
+ }
}
/* Data event with error status...fall through to NFC_ERROR_CEVT case */
diff --git a/src/nfc/tags/rw_t2t.c b/src/nfc/tags/rw_t2t.c
index de2de64..3976b3b 100644
--- a/src/nfc/tags/rw_t2t.c
+++ b/src/nfc/tags/rw_t2t.c
@@ -297,12 +297,20 @@ void rw_t2t_conn_cback (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data)
break;
case NFC_DATA_CEVT:
- if ( (p_data != NULL)
- &&( (p_data->data.status == NFC_STATUS_OK)
- ||(p_data->data.status == NFC_STATUS_CONTINUE) ) )
+ if (p_data != NULL)
{
- rw_t2t_proc_data (conn_id, &(p_data->data));
- break;
+ if ( (p_data->data.status == NFC_STATUS_OK)
+ ||(p_data->data.status == NFC_STATUS_CONTINUE) )
+ {
+ rw_t2t_proc_data (conn_id, &(p_data->data));
+ break;
+ }
+ else if (p_data->data.p_data != NULL)
+ {
+ /* Free the response buffer in case of error response */
+ GKI_freebuf ((BT_HDR *) (p_data->data.p_data));
+ p_data->data.p_data = NULL;
+ }
}
/* Data event with error status...fall through to NFC_ERROR_CEVT case */
diff --git a/src/nfc/tags/rw_t3t.c b/src/nfc/tags/rw_t3t.c
index 7db0fac..f8ec361 100644
--- a/src/nfc/tags/rw_t3t.c
+++ b/src/nfc/tags/rw_t3t.c
@@ -2369,6 +2369,12 @@ void rw_t3t_conn_cback (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data)
rw_t3t_data_cback (conn_id, &(p_data->data));
break;
}
+ else if (p_data->data.p_data != NULL)
+ {
+ /* Free the response buffer in case of error response */
+ GKI_freebuf ((BT_HDR *) (p_data->data.p_data));
+ p_data->data.p_data = NULL;
+ }
/* Data event with error status...fall through to NFC_ERROR_CEVT case */