Negative encoding value crashes the decoder
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in String.Encoding+JSONCodable.swift:107 and trace the numeric handling through Value.swift:94. Run the reproducer with negative and above-Int.max encoding values, then verify decoding throws an error instead of trapping and that xcprojformatter no longer exits with a crash.
Written by the indexing model from the issue text.
Description
A file reference with a negative encoding traps instead of throwing:
let json = #"{"default-configuration":"Debug","localizations":{"development":"en"},"files":[{"path":"a.txt","encoding":-1}]}"#
_ = try XCSchema.Project(jsonRepresentation: Data(json.utf8))
// Fatal error: Negative value is not representable
xcprojformatter dies the same way (exit 133).
It's UInt(Int(with: coder)) in String.Encoding+JSONCodable.swift:107. Values above Int.max (e.g. 9223372036854775808) crash too, because NSNumber.intValue in Value.swift:94 wraps them negative. UInt(exactly:) plus a thrown error would fix it.
main @ c132630, macOS 26, Swift 6.3.3
- Dominant language
- Swift
- Stars
- 384
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apple/xcode-project-format
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
apple/xcode-project-format#7 · 1 reaction ·
All issues in apple/xcode-project-format
Similar issues
-
type: docs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
googleapis/google-cloud-swift#971 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
manaflow-ai/cmux#13417 ·
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ionic-team/capacitor#8616 ·