Avoid possible resource leaks by boost::scoped_array

Change-Id: I54a175ce1e4cb624d94770ee849d97675987e7b2