Avoid possible resource leaks with boost::scoped_ptr

Change-Id: Ic6e8482dfb022f32532b5c1a6e045092c3485106