Avoid possible resource leaks by boost::scoped_array

Change-Id: Ibf92b3098c50388d8b6d27f4476e613a1f8918b5