Fix crash when calling error callback.