gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.44k stars 298 forks source link

[Crash] Crash when rendering string of `Array(repeating: "hello,\n", count: 250).joined()` #312

Open mas0n-sun opened 5 months ago

mas0n-sun commented 5 months ago

Describe the bug

I found that using Markdown with a string containing 250 \n characters causes a crash. Paste the following code into the Demo project under the Repo to reproduce.

struct CodeView: View {
  var body: some View {
    DemoView {
      Markdown(Array(repeating: "hello,\n", count: 250).joined())
    }
  }
}

Below is the crash screenshot. In the SwiftUI project, I am unable to determine the specific cause. If there are any good debugging methods, please let me know. Could you please attach the crash screenshot here? Additionally, if you could provide more details about the error message or the context in which the crash occurs, it would help in suggesting effective debugging methods for your SwiftUI project.

Screenshot 2024-04-30 at 14 17 45 Screenshot 2024-04-30 at 14 18 47

Checklist

Steps to reproduce

  1. Copy the code from the description into ContentView in the Demo project.
  2. Run the project.
  3. A crash occurs.

Expected behavior

I hope to resolve this crash as soon as possible. If needed, I can offer assistance.

Version information