Avoid possible resource leaks by boost::scoped_array

Change-Id: Ibc90eba9f336b649a968f584f2b36139c847d348