Avoid possible resource leaks by boost::scoped_array

Change-Id: I7b72c5680d5665b3f1f720f50a2d3ea6fc0c3e39