Fix a potential segfault and various potentail refcount leaks
in the cast() function.
1 file changed