codebots-ltd / TBXML

Super-fast, lightweight, easy to use XML parser for the Mac & iOS
http://www.71squared.com
578 stars 195 forks source link

Array access result in null pointer dereference. #16

Open mkpatil opened 11 years ago

mkpatil commented 11 years ago

After upgrading XCode to 4.6, I got above analyze warnings. Screen Shot 2013-02-04 at 7 22 28 PM Screen Shot 2013-02-04 at 7 22 18 PM Screen Shot 2013-02-04 at 7 22 42 PM

mkpatil commented 11 years ago

@Tpbradley Please help me on above issue.

Tpbradley commented 11 years ago

I've had a quick look and it looks like xcode is showing errors because there is a potential that some variables could be set to nil and accessed further on in the code. For example, in the code just above, currTBXMLElement could be set to nil, yet it's accessed layer on by currTBXMLElement->nextSibling.

The fix is to simply check currTBXMLElement contains a value before using it. The other errors look to be the same problem.

mkpatil commented 11 years ago

@Tpbradley I tried few code snippet as per your suggestion but it didn't work. I think something goes wrong, I just want to know that when can we expect this update or commit so that we can upgrade TBXML library as early as possible with this new fix.

Greensource commented 11 years ago

Hi, you must first check nullity of 'bytes'. I wrote that to fix warning: "if (bytes) bytes[bytesLength] = 0;"