incorrect list handling in copy_small_ranges
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c
- Domain
- operating-systems
Research direction
Start in src/malloc-graph.c at copy_small_ranges and trace the allocation-failure path after a partially copied list has been built. Verify the failure path cannot retain a link into the original live list, and use the project’s existing test or allocation-failure checks if available to confirm that cleanup does not double-free.
Written by the indexing model from the issue text.
Description
In src/malloc-graph.c, the copy_small_ranges function is defined as:
static bool copy_small_ranges(SmallRange **copy, SmallRange *range) {
for (; range; range = range->next) {
*copy = malloc(sizeof(**copy));
if (!*copy) {
return false;
}
**copy = *range;
copy = &(*copy)->next;
}
return true;
}
If malloc fails during any iteration other than the first:
**copy = *rangecopy-assigns the entire struct, which includes copying the original list'srange->nextpointer.copy = &(*copy)->nextshifts the assignment target to thenextpointer of the newly allocated range.- When the subsequent
mallocfails, the loop exits withfalsewithout setting*copy(thenextpointer of the prior allocated node) toNULL. - The partially copied list remains linked to the original live list starting from
range->next.
This behavior leads to double-free corruption.
- Dominant language
- C
- Stars
- 67
- Forks
- 40
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Comfy-Org/comfy-aimdo
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Comfy-Org/comfy-aimdo#117 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Comfy-Org/comfy-aimdo#114 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
Comfy-Org/comfy-aimdo#112 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Comfy-Org/comfy-aimdo#101 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Comfy-Org/comfy-aimdo#100 · 2 comments · 1 reaction ·
All issues in Comfy-Org/comfy-aimdo
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·