Avoid possible resource leaks by boost::scoped_array

Change-Id: I14e1f7ef217eb5e8e9db9f8962af868ab0a4ab81