arduino / arduino/ArduinoCore-mbed
Tone.cpp memory leak
- Dominant language
- C
- Stars
- 411
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
Tone.cpp has a small memory leak. void Stop() set pointer pin to nullptr and clears the pointer before the destructor is called, which later attempts to delete pin. Since the pointer was already set to nullptr, the dynamically allocated mbed::DigitalOut instance is never deleted, leading to a memory leak every time a new Tone object is created.
Fixed by removing pin=0 and letting the destructor delete pin.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in Tone.cpp by reading void Stop() and the Tone destructor, focusing on the lifetime of the dynamically allocated mbed::DigitalOut instance. Confirm that repeated Tone object creation does not leave the instance undeleted when Stop() runs, and verify that the destructor still owns cleanup when the issue is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100