Skip to content

fix(jpeg2000): Suppress leak when reading with OpenJPH#5098

Merged
lgritz merged 2 commits intoAcademySoftwareFoundation:mainfrom
lgritz:lg-openjphleak
Mar 23, 2026
Merged

fix(jpeg2000): Suppress leak when reading with OpenJPH#5098
lgritz merged 2 commits intoAcademySoftwareFoundation:mainfrom
lgritz:lg-openjphleak

Conversation

@lgritz
Copy link
Collaborator

@lgritz lgritz commented Mar 18, 2026

The jph_infile class itself did not change, it just moved up in the file to be defined before it was used. It's the use of the persistent unique_ptr that fixes the leak.

The jph_infile class itself did not change, it just moved up in the
file to be defined before it was used. It's the use of the persistent
unique_ptr that fixes the leak.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Collaborator Author

lgritz commented Mar 18, 2026

The Mac Intel CI failure doesn't appear to be at all related to this PR.

@lgritz
Copy link
Collaborator Author

lgritz commented Mar 23, 2026

Comments? Don't let the size of the diff fool you -- the big change is just code movement, not editing. It's only a few lines of changed code to convert a raw allocation (that could leak) to a unique_ptr that can't.

opj_stream_t* m_stream;
bool m_keep_unassociated_alpha; // Do not convert unassociated alpha
#ifdef USE_OPENJPH
std::unique_ptr<jph_infile> m_jphinfile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we shift this down to the existing USE_OPENJPH section at the bottom of the class since this belongs with the codestream member.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

certainly

…related

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Copy link
Contributor

@jessey-git jessey-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@lgritz lgritz merged commit 6145def into AcademySoftwareFoundation:main Mar 23, 2026
57 of 58 checks passed
@lgritz lgritz deleted the lg-openjphleak branch March 23, 2026 20:52
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Mar 24, 2026
…reFoundation#5098)

The jph_infile class itself did not change, it just moved up in the file
to be defined before it was used. It's the use of the persistent
unique_ptr that fixes the leak.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
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

Successfully merging this pull request may close these issues.

2 participants