Avoid possible resource leaks by boost::scoped_array

Change-Id: I8b57f970b31b12902e3772c3306b71379b8d3fe5