cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.27k stars 939 forks source link

Fixing Exr invalid channel write #2224

Closed gaborpapp closed 3 years ago

gaborpapp commented 3 years ago

The vector storing the channel data should have a reserved size otherwise the pointers might get invalid if the vector is resized.

richardeakin commented 3 years ago

I guess when the vector resize gets called, the Channel copy constructor is getting called instead of the move, which is what I thought C++11 was all about. We can merge this PR to fix the problem, but it also seems like we need to figure out how to enable the move constructor for vector<ChannelT>s..

Also only just realized that this PR fixes #2222 (I think it didn't get auto linked because of the 'cinder' prefix in your commit comment).

gaborpapp commented 3 years ago

I checked this in Linux and macOS too. GCC and Clang both wrote broken exr's without this change. So it's probably not a compiler specific issue.

richardeakin commented 3 years ago

I guess worth noting that we should look into making Channel and Surface classes movable when held in std::vector, but as I don't have the time to look into that at the moment will merge this as it is a clear bugfix for the current version.

Thanks for checking on other platforms, good find!