h2zero / esp-nimble-cpp

C++ library for the esp32 NimBLE stack based on and mostly compatible with @nkolban cpp_utils BLE library.
https://h2zero.github.io/esp-nimble-cpp/
Apache License 2.0
181 stars 62 forks source link

NimBLEService::start() runtime error with esp-idf v5.3 #233

Open ubichsel opened 5 days ago

ubichsel commented 5 days ago

Hey h2zero

First let me thank you for your very helpful work you did with this library. It is so much nicer to work the the C++ classes instead of dealing with all the c structures. Recently I updated to esp-idf v5.3 and I discovered a run time error (accessing invalid memory address) when calling NimBLEService::start()). The ble_gatt_chr_def structure in this NIMBLE version contains new a cpfd attribute which is later checked for NULL in ble_gatts_count_resources (file ble_gatts.c). This attribute is left uninitialized in function NimBLEService::start(). When I add the line "pChr_a[i].cpfd = NULL;" after "pChr_a[i].val_handle = &(*chr_it)->m_handle;" it works again without any problems.

Would be nice if you can have a look and (if you agree) patch it in this repo (in the way it works for both idf versions, e.g. #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)).

h2zero commented 5 days ago

Hello @ubichsel, this issue was addressed in the master branch in #150