Avoid possible resource leaks by boost::scoped_array

Change-Id: I97dc3d073cca1584f195b592cec9ef2d8d0dbd23