-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened
StarknetTypedData.Element implements CustomStringConvertible as follows:
extension StarknetTypedData.Element: CustomStringConvertible {
public var description: String {
switch self {
case let .string(s):
s
case let .decimal(n):
String(n)
case let .signedDecimal(n):
String(n)
case let .felt(f):
f.toHex()
case let .signedFelt(f):
f.toHex()
case let .bool(b):
String(b)
case .object:
String(describing: self)
case .array:
String(describing: self)
}
}
}If the element is an object or an array, this will result in an infinite loop, since String(describing: self) will just call description from the CustomStringConvertible implementation again, and again until the stack overflows.
If you add the following test to TypedDataTests.swift you will see the crash:
func testDescription() {
let description = String(describing: Self.CasesRev0.tdFeltArr)
print(description)
}I chose Self.CasesRev0.tdFeltArr as it contains an array element.
Stack trace
Steps to reproduce
- Create a
StarknetTypedDatathat has an array or object element. - Pass it to
String(describing:)
It will crash.
SDK Version
v0.13.1
Language version
Swift 6.2
Is there an existing issue for this?
- I have searched the existing issues and verified no issue exits for this problem.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working