Avoid possible resource leaks by boost::scoped_array

Change-Id: I3d26325995995f658cd6adcc80e0716cfcee7de0