I get a segfault if the old cdio_ object is not destroyed here in the way @davidsansome pointed out. Also cdio_ needs to be initialized to NULL in the constructor.