state_tracker: Guard against a possible calloc failure and fix state_tracker_free

Checks if the passed in tracker is actually valid before attempting to free its members.
Merge pull request #993 from lioncash/calloc

state_tracker: Guard against a possible calloc failure and fix state_tracker_free