ofFbo copy constructor and operator= fails to copy defaultTextureIndex #1665

Closed
pappis opened this Issue Oct 24, 2012 · 5 comments

Projects

None yet

4 participants

@pappis
pappis commented Oct 24, 2012

This means that if the copy constructor is used to create a new instance of ofFbo, the defaultTextureIndex member variable will contain a garbage value (whatever happened to be at the memory address now taken up by the member variable).
For me, this causes crashing if I for example have a vector of ofFbo's that I resize to cerate new elements in it:
std::vector myFbos;
myFbos.resize(2);
// myFbos[0] and myFbos[1] will now contain random values in defaultTextureIndex, and any attempt to use them in a way that uses that member var will probably cause a crash.

The solution that solves the problem for me is to simple add a line like this:

defaultTextureIndex = mom.defaultTextureIndex;

to both the copy constructor and operator=.

@kylemcdonald
Contributor

This sounds like the correct solution, could you issue a quick pull request? Or whoever is the next to edit/update ofFbo can take this into account :)

On Oct 24, 2012, at 2:08 PM, pappis notifications@github.com wrote:

This means that if the copy constructor is used to create a new instance of ofFbo, the defaultTextureIndex member variable will contain a garbage value (whatever happened to be at the memory address now taken up by the member variable).
For me, this causes crashing if I for example have a vector of ofFbo's that I resize to cerate new elements in it:
std::vector myFbos;
myFbos.resize(2);
// myFbos[0] and myFbos[1] will now contain random values in defaultTextureIndex, and any attempt to use them in a way that uses that member var will probably cause a crash.

The solution that solves the problem for me is to simple add a line like this:

defaultTextureIndex = mom.defaultTextureIndex;

to both the copy constructor and operator=.


Reply to this email directly or view it on GitHub.

@arturoc arturoc added a commit to arturoc/openFrameworks that referenced this issue Oct 24, 2012
@arturoc arturoc ofFbo: copy constructor and equal operator lack initialization of som…
…e vars. Fixes #1665
bf1f392
@arturoc
Member
arturoc commented Oct 24, 2012

thanks, it's fixed now

@arturoc arturoc closed this Oct 24, 2012
@bilderbuchi
Member

@arturoc I thought we agreed at the last dev-meet to not push non-trivial things into master without a PR (even a minimal one) anymore, for easier compilation of changelogs out of merged PRs? I feel this bugfix would warrant mentioning in the changelog, or am I wrong?

@arturoc
Member
arturoc commented Oct 25, 2012

i think this is trivial/obscure enough, to not need to be detailed in the changelog. imo, is just a small bugfix that can go in the changelog as a generic "several bugfixes"

@bilderbuchi
Member

alright :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment