-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when parsing packed repeated uint64
field with length 0 in Swift
#3043
Comments
thanks a lot for this report! Would it be possible to ask you to attempt something similar in Wire 4.5 or Wire 4.6 so we can see if this regressed at some point or it was always an issue? I will attempt to do it myself using the test you provided too but I can do so a little bit later in the week. |
Also feel free to open a PR! |
For sure – I just replayed these changes on top of the |
There's a number of additional |
Hi! Thanks for maintaining Wire – I'm loving using it.
I'm using Wire to generate Swift code for proto types and parsing, and am running into a crash when deserializing that I think is a bug in the Swift
ProtoReader
.Specifically, I'm using my in-code Wire-generated Swift models to assemble a type that has a
[UInt64]
field on it, which I'm setting to[]
, and serialize it. When I later try and deserialize that serialized proto, I'm hitting thisfatalError
:Digging into it a little, I'm seeing just before the crash that Wire is trying to decode a
repeated uint64
field:Poking around at those breakpoints, it looks like
length
is0
:There's a comment in that method that suggests that when we actually go to decode a
T: UInt64
for this array, we'll setstate
to.tag
(the originalfatalError
was becausestate
was not being set to.tag
). However, sincelength
is0
(which makes sense, since this array is empty) we'll never actually decode aUInt64
, andstate
remains.lengthDelimited
rather than getting reset to.tag
.I'm able to reproduce this minimally by adding the following to
ProtoReaderTests.swift
:However, if I add the following shim to
ProtoReader.swift
locally, it works:So perhaps this method sould check for
length == 0
and manually resetstate = .tag
and early-return?Please let me know if there's more information I can provide. Thanks!
The text was updated successfully, but these errors were encountered: