Objective3 / ElementParser

ElementParser is lightweight Cocoa Framework (usable on the iPhone) to provide easy access to XML and HTML content.
http://touchtank.wordpress.com/element-parser/
421 stars 48 forks source link

One more static analysis item #3

Closed sixten closed 15 years ago

sixten commented 15 years ago

In the method parseHTML:delegate:selector:context:index:partial: (in NSString_HTML.m), you might want to set a default value for the local var len. Clang was able to find a path through the method where it doesn't get a value before it's passed to NSMakeRange() on line 458. Looks like it works like this:

Now, whether this is likely to actually happen, I couldn't say. I suspect you might be able to craft an input document that would do this, though. At any rate, take it for what it's worth. :-)

parisman commented 15 years ago

nice detective work. I'll add the initializer although I am not convinced that it can actually occur.

sixten commented 15 years ago

Well, that definitely happens with static analysis bugs: the compiler doesn't know anything about usage.

parisman commented 15 years ago

best to keep the compiler happy! BTW, any feedback on ElementParser? Useful? Have you/would you recommend?