Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Memory leak of m_paucEncodingBits in Etc::Image #56

Closed
C0lumbo opened this issue Jun 17, 2021 · 1 comment
Closed

Memory leak of m_paucEncodingBits in Etc::Image #56

C0lumbo opened this issue Jun 17, 2021 · 1 comment

Comments

@C0lumbo
Copy link

C0lumbo commented Jun 17, 2021

In Image::~Image, the code to free m_paucEncodingBits is commented out. Presumably this is because one of the Image::Image constructors allows the caller to pass in their own encoding bits so calling delete[] would be unsafe in this scenario. However, in other codepaths, the class allocates it's own m_paucEncodingBits in the Image::Encode function which is never freed.

A possible solution would be to add a bool to Etc::Image to track whether or not it allocated m_paucEncodingBits, and free when necessary.

@C0lumbo C0lumbo closed this as completed Jun 17, 2021
@C0lumbo
Copy link
Author

C0lumbo commented Jun 17, 2021

Actually looking at the behaviour of Etc::EncodeMipmaps Etc::Encode it's clear that m_paucEncodingBits must persist beyond the lifetime of the Etc::Image so it's the callers responsibility to free the memory. Perhaps that could be made clearer somehow, but there's no bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant