The problem was that you can have certain situations were there is no active object.
Just adding a check to see if we actually have one or not solves this issue.
I've also looked at other parts of the code that uses the functions from object_utils.c and those already have NULL checks it seems.