Skip to content

bug in error handling? #10

@jdmuys

Description

@jdmuys

I am receiving empty data from well formed YAML (at least according to http://yaml-online-parser.appspot.com/). I traced through the code and I believe there is a bug in the code when the optional NSError argument passed is not nil. This happens in:

 + (NSMutableArray *) YAMLWithStream: (NSInputStream *) stream  options: (YAMLReadOptions) opt error: (NSError **) error

Where you find this test:

  if (error) {
      yaml_document_delete(&document);
  }

If the error passed is not nil, then this test passes even if there is no actual parsing error. I believe the test should be:

  if (*error) {
      yaml_document_delete(&document);
  }

(also note that the pattern is not faithful to the Cocoa NSError pattern where you should only look at the NSError if you diagnosed the occurrence of an error in some other way. A non-nil error is not necessarily a good test for error, as we could have warnings, non-fatal errors, recovered errors… Now of course, this is no big deal. You can diverge from Cocoa patterns if you like).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions