CymChad / CymChad/BaseRecyclerViewAdapterHelper

BaseNodeAdapter.kt中有一个bug会导致数组越界

Open
#3,424 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
24.6k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

`
private fun removeNodesAt(position: Int): Int {
if (position >= data.size) {
return 0
}
// 记录被移除的item数量
var removeCount = 0

    // 先移除子项
    removeCount = removeChildAt(position)

    // 移除node自己
    this.data.removeAt(position)                                  !!!!!!!!!!!!!!注意这里, 已经移除了position处的item
    removeCount += 1

    val node = this.data[position]                                !!!!!!!!!!!!!!此时再去获取这个位置上的item,如果item总数为1, 那么这里就越界了
    // 移除脚部
    if (node is NodeFooterImp && node.footerNode != null) {
        this.data.removeAt(position)
        removeCount += 1
    }
    return removeCount
}

`
屏幕截图 2021-01-22 084036

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue points to BaseNodeAdapter.kt and removeNodesAt(position). Read that method first and reproduce the single-item case described in the report; verify the removal order and footer handling without assuming an index remains valid after removal. Done means the reported ArrayIndexOutOfBoundsException no longer occurs and existing node-removal behavior is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.