While the code does assert against NULL, that doesn't really stop potential for NULL in non-debug code. Adding an explicit NULL check, which also keeps the clang static analyzer happy.
Suppress some compiler warnings in the ffi module.