Fixed an issue with some pointers being wrongly deleted after they got owned by an auto_ptr variable.

See https://github.com/opencor/opencor/issues/340.