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

Call to image.with_shallow_pixels will free pixels used in previous call to with_shallow_pixels #51

Closed
Geof23 opened this issue Feb 7, 2021 · 3 comments
Assignees

Comments

@Geof23
Copy link

Geof23 commented Feb 7, 2021

The notes in image-c++.h indicate that, with this function, shallow data is not deleted upon image destruction.

It's a natural assumption that this would include reuse of the image object.

(SHA 6250cce)

@Geof23
Copy link
Author

Geof23 commented Feb 7, 2021

(suggested fix)

--- a/src/bindings/c++/image-c++.cpp
+++ b/src/bindings/c++/image-c++.cpp
@@ -303,7 +303,8 @@ image& image::with_shallow_pixels(void *pixels)

 image& image::with_shallow_pixels(void *pixels, unsigned pixels_size)
 {
-    sail_free(d->pixels);
+    if(!d->shallow_pixels)
+        sail_free(d->pixels);

     d->pixels         = nullptr;
     d->pixels_size    = 0;

@HappySeaFox
Copy link
Owner

Thanks for the report! I'll look into it.

@HappySeaFox HappySeaFox self-assigned this Feb 8, 2021
@Geof23
Copy link
Author

Geof23 commented Feb 8, 2021 via email

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

2 participants