Avoid possible resource leaks by boost::scoped_array

Change-Id: If9b4a70895ae22ef40d9d1fa83ecbf9131c836af