-
Notifications
You must be signed in to change notification settings - Fork 609
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
Fix memory leak in libjpeg-turbo decoder implementation in case of corrupted images #4138
Conversation
…rrupted images Signed-off-by: Joaquin Anton <janton@nvidia.com>
return nullptr; | ||
} | ||
|
||
jpeg_create_decompress(&cinfo); | ||
auto destroy_cinfo = AtScopeExit([&cinfo]() { | ||
jpeg_destroy_decompress(&cinfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is crucial. Some paths ended up without calling jpeg_destroy_decompress
which was the source of the leak
@@ -546,23 +524,6 @@ uint8* Uncompress(const void* srcdata, int datasize, | |||
return dstdata; | |||
} | |||
|
|||
uint8* Uncompress(const void* srcdata, int datasize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dead code
@@ -606,196 +567,5 @@ bool GetImageInfo(const void* srcdata, int datasize, int* width, int* height, | |||
return true; | |||
} | |||
|
|||
// ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dead code
FewerArgsForCompiler argball(datasize, flags, nwarn, | ||
std::move(allocate_output)); | ||
const UncompressFlags& flags) { | ||
FewerArgsForCompiler argball(datasize, flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess now we could get rid of that, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used to keep some state too, apparently. So I'll leave it for now.
FewerArgsForCompiler argball(datasize, flags, nwarn, | ||
std::move(allocate_output)); | ||
const UncompressFlags& flags) { | ||
FewerArgsForCompiler argball(datasize, flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used to keep some state too, apparently. So I'll leave it for now.
!build |
CI MESSAGE: [5548261]: BUILD STARTED |
CI MESSAGE: [5548261]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [5550334]: BUILD STARTED |
CI MESSAGE: [5550334]: BUILD PASSED |
FewerArgsForCompiler argball(datasize, flags, nwarn, | ||
std::move(allocate_output)); | ||
const UncompressFlags& flags) { | ||
FewerArgsForCompiler argball(datasize, flags); | ||
uint8* const dstdata = UncompressLow(srcdata, &argball); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here we releasded the ownership of the memory and the caller of the function must take care of releasing it, right? As a food for thought, maybe this function should also return smart pointer? It looks a bit brittle.
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [5557749]: BUILD STARTED |
CI MESSAGE: [5557749]: BUILD FAILED |
CI MESSAGE: [5557749]: BUILD PASSED |
…rrupted images (NVIDIA#4138) Signed-off-by: Joaquin Anton <janton@nvidia.com>
…rrupted images (#4138) Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton janton@nvidia.com
Category:
Bug fix
Description:
.release()
on the successful path.Additional information:
Affected modules and functionalities:
fn.decoders.image
Key points relevant for the review:
Replacement of manual memory handling with unique_ptr
Tests:
Checked memory consumption locally with the dataset provided in the mentioned issue
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: DALI-2944