Check for the right function pointer

This code checked whether one function pointer was non-null,
but the went on to call a different function pointer. Check
for the one that actually was called.
Merge pull request #500 from mstorsjo/fix-func-ptr-check

Check for the right function pointer