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

Fix memory corruption & leaks in Image #240

Merged
merged 1 commit into from
Aug 23, 2021

Conversation

darksylinc
Copy link
Contributor

Image was calling SwapRedBlue unconditionally based on compile-time
values.

That meant that greyscale images would try to swap Red and Blue
channels, but there is only one channel. This resulted in artifacts on
the final image as well as memory corruption as the last pixels would be
swapped against out of bound regions.

Additionally, there were several instances where FIBITMAP handles were
leaking.

Signed-off-by: Matias N. Goldberg [email protected]

🦟 Bug fix

No ticket was issued.

Summary

How to repro: Just load a greyscale 8-bit image and use a tool like valgrind or ASAN to see the corruption.
The memory leaks will be hard to spot though.

It is possible this fix should be backported to older releases

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Image was calling SwapRedBlue unconditionally based on compile-time
values.

That meant that greyscale images would try to swap Red and Blue
channels, but there is only one channel. This resulted in artifacts on
the final image as well as memory corruption as the last pixels would be
swapped against out of bound regions.

Additionally, there were several instances where FIBITMAP handles were
leaking.

Signed-off-by: Matias N. Goldberg <[email protected]>
@codecov
Copy link

codecov bot commented Aug 21, 2021

Codecov Report

Merging #240 (921abce) into ign-common4 (e70a75d) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-common4     #240      +/-   ##
===============================================
+ Coverage        76.99%   77.02%   +0.02%     
===============================================
  Files               74       74              
  Lines            10563    10579      +16     
===============================================
+ Hits              8133     8148      +15     
- Misses            2430     2431       +1     
Impacted Files Coverage Δ
graphics/src/Image.cc 68.75% <100.00%> (+1.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e70a75d...921abce. Read the comment docs.

@mjcarroll mjcarroll merged commit 4c0ee89 into gazebosim:ign-common4 Aug 23, 2021
peci1 added a commit to peci1/ign-common that referenced this pull request Jan 5, 2022
Fixes ign-gui#341.

Signed-off-by: Martin Pecka <[email protected]>
ahcorde pushed a commit that referenced this pull request Jan 5, 2022
Fixes ign-gui#341.

Signed-off-by: Martin Pecka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏢 edifice Ignition Edifice 🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants