Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

thekurtovic
Copy link
Collaborator

Fixes heap corruption observed on CONFIG_HEAP_POISONING_COMPREHENSIVE.
Resolves #277

Fixes heap corruption observed on CONFIG_HEAP_POISONING_COMPREHENSIVE.
@thekurtovic
Copy link
Collaborator Author

I have no idea what's going on here. Checked for other references on m_callbackSent but can't see anything which would require the increment to happen before the callback.
I originally thought calling pScan->stop(); explicitly was causing issues (like #242), as it appeared as though letting NimBLEClient::connect() implicitly stop the scan would avoid the issue, but it seems to not be true anymore.

Copy link
Owner

@h2zero h2zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thekurtovic
Copy link
Collaborator Author

It makes sense now.
Incrementing after meant that there was a risk of a dangling pointer since the scan could be stopped within the onResult callback. Best to always have the callback "last" when possible.

@h2zero
Copy link
Owner

h2zero commented Dec 25, 2024

Yes, I'm not sure why it was changed but that would be the reason for the crashing.

@h2zero h2zero merged commit 09297fb into h2zero:master Jan 2, 2025
59 checks passed
thorrak added a commit to thorrak/NimBLE-Arduino that referenced this pull request Jan 2, 2025
@thekurtovic thekurtovic deleted the fix-heap-corruption branch January 2, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Heap corruption
2 participants