Avoid possible resource leaks by boost::scoped_array

Change-Id: Iffc9d1ca971610bad9b3dd2bd9a6cd00f02ff39b