Fix leaks and null dereferences in net_crypto