Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI.end incorrect check #442

Closed
paulvha opened this issue Jan 10, 2022 · 2 comments
Closed

SPI.end incorrect check #442

paulvha opened this issue Jan 10, 2022 · 2 comments

Comments

@paulvha
Copy link
Contributor

paulvha commented Jan 10, 2022

I have created a pull request for SPI.end. In the current setup, it tries to remove the dev-instance if it does NOT exist (which only happens if you have NOT called SPI.begin()).

    if (! dev) {
        delete dev;
    }

As a result the dev-instance is never removed, memory released, when the instance was set

it should read :


    if (dev) {
        delete dev;
    }

regards,
Paul

@Wenn0101
Copy link
Contributor

Fix is in dev and scheduled for release 2.2.1

@PaulZC
Copy link
Contributor

PaulZC commented Apr 15, 2022

Hi @Wenn0101 ,

Are we sure that delete sets dev to NULL?

I'm wondering if the end code should be:

void arduino::MbedSPI::end() {
    if (dev) {
        delete dev;
        dev = NULL;
    }
}

I can't take credit for this. I've seen @paulvha add the NULL in other places.

Cheers,
Paul

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

No branches or pull requests

3 participants