Fix possible NULL pointer dereference

The assertion should be done before we assign our callback pointer to prevent an unwanted segfault.

Can't believe I botched that on my original bug fix! *facepalm*

Thanks!