[runtime] Fix a memory leak.
[runtime] Fix reading invalid memory during some checks for remoting types.