Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
#ifdef
to silence a clang
static analyzer false positive wa…
…rning. The current (at the time of this writing) version of the `clang` static analyzer is complaing that the `objects` pointer is `NULL`. This is a false positive warning from the analyzer.
- Loading branch information
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im afraid I see it as true.. the objectPtr could be NULL and it would crash.
objectPtr = NULL
range = NSMakeRange(1,1)
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #84 (comment)
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Daij-Djan, you could write it as this:
if ((true) && (true)) { raise }
as objectsPtr == NULL will be true
and NSMaxRange of range 1,1 will also be greater then 0
seems like the compiler does not notice throwing an exception will stop the execution right there
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schubter:: yes sorry blush I meant a zero range! (e.g. 1,0) => the idea is that the if doesn't have to trigger ....
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wwwang89 This is not the place to ask such questions. GitHub is for reporting issues and requesting features. If you want to ask technical questions like how to download files from GitHub, either read the git/GitHub documentation or ask this question on a forum such as StackOverflow.
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to solve this without silencing the analyzer would be to add this at the top of the method:
if (range.length == 0) return;
No need to start copying anything anyway when the range length is 0.
This avoids a crash when calling
[getObjects:NULL range:NSMakeRange(0, 0)]
, which is why the analyzer was complaining in the first place (so no false positive).8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONKit will crash in the ios9, 'NSTaggedPointString', i can't resolve it
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not be a useful answer, but why are you still using JSONKit?
NSJSONSerialization
has been available since iOS 5. There are no iOS devices you should be supporting that can't use it. This library hasn't been update since 2012. It's time to let it go.8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guykogus I know, but my team started use in early, so.. need some time.
now, i still resolve it...
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share the JSON string that you're trying to parse?
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guykogus after iOS9.0 ,like '0.4' , system change it become NSTaggedPointString, change '12345678' become CFString, NSTaggedPointString string will crash in the JSONKit, ‘- (NSString *)JSONString’ method.
Do you understand.
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No... please provide the JSON string and code you're using.
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guykogus , resolve it just now, #185
8215763
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a fork that handle tagged pointers the right way : see #158.