Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with nil error parameter #5

Closed
kristopherjohnson opened this issue Apr 20, 2012 · 1 comment
Closed

Crash with nil error parameter #5

kristopherjohnson opened this issue Apr 20, 2012 · 1 comment

Comments

@kristopherjohnson
Copy link
Contributor

TBXML provides this method, which simply invokes another method with a nil error pointer:

- (id)initWithXMLData:(NSData*)aData {
    return [self initWithXMLData:aData error:nil];
}

There are other similar methods (-initWithXMLFile:, -initWithXMLFile:fileExtension:, etc.).

Unfortunately, if an error does occur, then the error handling code will try to dereference that nil pointer, and the app crashes. Some error-handling code does check for a null pointer before dereferencing it, but some does not.

Callers can work around this issue by calling the variant of the method that requires an error pointer. However, as-is these methods can easily lead to a crash, so I propose one of these actions be taken:

  • Remove the methods that don't require an error parameter. Require callers to pass an error parameter.
  • Change the methods that pass nil pointers such that they instead use a local error variable.
  • Change the error-handling code so that it always checks for a null error before trying to dereference it.
@kristopherjohnson
Copy link
Contributor Author

I have submitted a pull request with a fix. See #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant