fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

Coverity: Create a copy of the object

Open JohnAFernandez opened this issue 2 years ago • 1 comments

Instead of returning the unique pointer, which would make it a shared unique pointer (bad). This method is only used to get the value stored in the config and the reference will be destroyed pretty quickly after being called. Sure, it is more efficient to use the pointer to get the info, but I don't think it's worth it to rewrite the methods here, and we don't need the efficiency since this is used to update the UI.

And it's not feasible to convert to shared pointer, since there are so many references to unique pointers in this code. It's just better to just make a quick copy here.

I have to turn this through a test, still.

JohnAFernandez avatar Dec 22 '23 00:12 JohnAFernandez

I'm still doing research, trying to figure out if this is complete. Because the json_t type seems to want to track the number of references to it, and I'm not sure why yet. (The previous method of incrementing the reference number is not really correct, because it never gets decremented again.)

JohnAFernandez avatar Dec 22 '23 00:12 JohnAFernandez