Skip to content
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

Index Validation and Safer Collection Handling in Eureka #2253

Open
gabzdyldaniel opened this issue Jan 29, 2024 · 0 comments
Open

Index Validation and Safer Collection Handling in Eureka #2253

gabzdyldaniel opened this issue Jan 29, 2024 · 0 comments

Comments

@gabzdyldaniel
Copy link

Describe the bug

Lack of Index Validation in UITableViewDelegate and UITableViewDataSource Implementations:

The current implementations of UITableViewDelegate and UITableViewDataSource within the Eureka library encounter issues when indices are beyond the data bounds of the form. Accessing an element with an index outside the bounds of form data leads to application crashes due to out-of-range index access. An optimal solution would involve the library performing index validation, returning default values or handling these cases safely when an index is out of bounds.

Safety Concerns in Form.replaceSubrange and Sections.replaceSubrange Methods:

In the Form.replaceSubrange method, there's an absence of a check to ensure that kvoWrapper._allSections contains the section being removed. The use of force unwrapping in kvoWrapper._allSections.firstIndex(of: section)! can cause the application to crash if the searched section is not found. This issue is also present in the Sections.replaceSubrange method. A safer approach would be to replace force unwrapping with more robust methods like if let or guard statements, ensuring the existence of an index before its usage.

Expected behavior

Index Validation in UITableViewDelegate and UITableViewDataSource:

When interacting with indices in UITableViewDelegate and UITableViewDataSource, the library should safely handle cases where indices are outside the bounds of the form data. Instead of the application crashing, the library should either return default values or gracefully handle these scenarios without causing runtime errors.

Safe Handling in Form.replaceSubrange and Sections.replaceSubrange Methods:

The methods Form.replaceSubrange and Sections.replaceSubrange should include checks to confirm the presence of a section in kvoWrapper._allSections before attempting to modify it. If a section is not found, the methods should fail gracefully, either by safely handling the absence or by providing a clear error message, rather than causing a crash through force unwrapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant