CFNumber: add missing break statements in CFNumberGetType#57
Open
DTW-Thalion wants to merge 2 commits into
Open
CFNumber: add missing break statements in CFNumberGetType#57DTW-Thalion wants to merge 2 commits into
DTW-Thalion wants to merge 2 commits into
Conversation
The objCType switch in CFNumberGetType (the bridged-NSNumber path) had no break statements, so every case fell through to the last and a bridged NSNumber of any type reported kCFNumberDoubleType. This also gave wrong results for CFNumberGetByteSize, CFNumberIsFloatType and equality of bridged numbers. Add Tests/CFNumber/gettype.m.
| /* CFNumberGetType on a bridged NSNumber must reflect the number's actual | ||
| * type. The objCType switch was missing its break statements, so every | ||
| * case fell through to kCFNumberDoubleType; an integer NSNumber wrongly | ||
| * reported kCFNumberDoubleType. */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
objCTypeswitch inCFNumberGetType(the bridged-NSNumberpath,CF_IS_OBJC) has nobreakstatements, so every case falls through tothe last (
kCFNumberDoubleType). A bridgedNSNumberof any type thereforereports
kCFNumberDoubleType, which also gives wrong results forCFNumberGetByteSize,CFNumberIsFloatType, and equality of bridged numbers.Fix
Add the missing
breakafter each case.Test
Tests/CFNumber/gettype.m: an integerNSNumbermust reportkCFNumberIntType. It returnskCFNumberDoubleTypebefore this change and thecorrect type after.
(A single integer case is used deliberately: gnustep-base represents small
long/short/charnumbers with anintobjCType, and float/doubleNSNumbers are tagged pointers that don't bridge through the CF FFI path — sointis the one case that exercises this switch portably.)