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

pico_graphics is not memory safe #887

Closed
jondurrant opened this issue Dec 22, 2023 · 3 comments
Closed

pico_graphics is not memory safe #887

jondurrant opened this issue Dec 22, 2023 · 3 comments
Labels
[- pico graphics library -] bug Something isn't working

Comments

@jondurrant
Copy link

frame_buffer is allocated with new but never destroyed even if the pico_graphics object is removed.

@Gadgetoid
Copy link
Member

Good spot- MicroPython handles frame_buffer allocation so we've not had much hitting this code path. Looks like, at least, it needs a managed flag and a corresponding delete in the class destructor.

There's also a method to replace the framebuffer, I'm not totally sure if that should be blocked if managed == true or just let the user get themselves into trouble-

void PicoGraphics::set_framebuffer(void *frame_buffer) {
this->frame_buffer = frame_buffer;
}

@Gadgetoid Gadgetoid added [- pico graphics library -] bug Something isn't working labels Jan 16, 2024
@jondurrant
Copy link
Author

Yes I moved to create my own buffers to make it memory safe.

I'd really recommend having a full unit test suite for these libraries. Perhaps use CPPUTest which will do the memory safe analysis for you. I have videos and examples of how on YouTube (https://youtu.be/_2-Mh3Kun6s) which might be an accelerator.

@Gadgetoid
Copy link
Member

I'd love unit testing across the libraries but I fear it might be an effort of quickly diminishing returns for a project of this scope- it's always been on my to-look-in-to-list though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[- pico graphics library -] bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants