fixed usage of invalid pointer