Fixed potential null dereference of error pointer