]> granicus.if.org Git - esp-idf/commitdiff
component/bt: Fix malloc fail lead to crash
authorxiewenxiang <xiewenxiang@espressif.com>
Wed, 30 May 2018 12:29:14 +0000 (20:29 +0800)
committerxiewenxiang <xiewenxiang@espressif.com>
Thu, 31 May 2018 05:31:27 +0000 (13:31 +0800)
components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c

index 74ae46a6edba35650840b48c96b9730f52a19f00..fc043914eb0ceb6235f014aade5b7a9b74d7d926 100644 (file)
@@ -506,6 +506,8 @@ static void btc_gatts_cb_param_copy_req(btc_msg_t *msg, void *p_dest, void *p_sr
         if (p_dest_data->req_data.p_data != NULL) {
             memcpy(p_dest_data->req_data.p_data, p_src_data->req_data.p_data,
                    sizeof(tBTA_GATTS_REQ_DATA));
+        } else {
+            BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
         }
         break;
 
@@ -759,6 +761,9 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
         param.write.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
         param.write.trans_id = p_data->req_data.trans_id;
         memcpy(param.write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
+        if (p_data->req_data.p_data == NULL) {
+            break;
+        }
         param.write.handle = p_data->req_data.p_data->write_req.handle;
         param.write.offset = p_data->req_data.p_data->write_req.offset;
         param.write.need_rsp = p_data->req_data.p_data->write_req.need_rsp;
@@ -775,6 +780,9 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
         param.exec_write.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
         param.exec_write.trans_id = p_data->req_data.trans_id;
         memcpy(param.exec_write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
+        if (p_data->req_data.p_data == NULL) {
+            break;
+        }
         param.exec_write.exec_write_flag = p_data->req_data.p_data->exec_write;
 
         btc_gatts_cb_to_app(ESP_GATTS_EXEC_WRITE_EVT, gatts_if, &param);