Skip to content

Stack overflow when comparing two nil objects of type [String: Any]?  #186

@AlexWoodblock

Description

@AlexWoodblock

Describe the bug
Extension that overrides == operator for Optional<[String:Any]> causes infinite loop with stack overflow when comparing two nil optionals of this type.

To reproduce

  1. Add LaunchDarkly 4.0 to Podfile:
    pod 'LaunchDarkly', '~>4.0.0'
  2. Run pod install
  3. Add following code anywhere in application
let dict1: [String: Any]? = nil
let dict2: [String: Any]? = nil

if dict1 == dict2 {
    print("This will never be printed")
}
  1. Run the application and make sure the code executes.
  2. Application will crash due to stack overflow because of line 79 in LaunchDarkly/Extensions/Dictionary.swift - it enters recursive loop in case of lhs and rhs both being nil.

Expected behavior
== should return true for comparison of two nil [String:Any]?objects.

SDK version
4.0.0

Language version, developer tools
Swift 5

OS/platform
iOS 12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions