YAML.framework
YAML.framework copied to clipboard
bug in error handling?
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).
Thanks! Was about to submit the same error but will now upgrade to the latest and greatest version.