diff options
author | Jizhou Liao <Jizhou.Liao@nxp.com> | 2016-03-22 12:08:11 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2016-05-11 19:25:01 +0200 |
commit | 5340dae86f4e2bb697cccd0f586501b52a784db5 (patch) | |
tree | ca67be2e117d2f308bdb3e7c5bdf11847a0e9428 | |
parent | b1b86f94acdddb55f0f13bc959ddfa9289f4cf2e (diff) | |
download | libnfc-nci-5340dae86f4e2bb697cccd0f586501b52a784db5.tar.gz |
Free memory in case of error response
In case of NFC_DATA_CEVT with error response,
p_data is allocated as p_msg from nfc_main_hal_data_cback(),
here to free this buffer to avoid memory leak.
Bug: 28181917
Change-Id: I74bbb5c2f7956eb246b38c25a1e8c56922ee56ab
-rw-r--r-- | src/nfc/tags/rw_t1t.c | 16 | ||||
-rw-r--r-- | src/nfc/tags/rw_t2t.c | 18 | ||||
-rw-r--r-- | src/nfc/tags/rw_t3t.c | 6 |
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 */ |