Skip to content

Bug: Child head can be nil #41

@AtakanPehlivanoglu

Description

@AtakanPehlivanoglu

Issue Description

func (trie *Trie) compact() *Trie has a condition where child head is nil and causes nil pointer panic due to corrupted state or race condition.

Line of Code

	// If any item is set, we cannot compact since we want to retain
	// the ability to do searching by key. This makes compaction less usable,
	// but that simply cannot be avoided.

	if trie.item != nil || child.item != nil {
		return trie
	}

Proposed Mitigation

	// If any item is set, we cannot compact since we want to retain
	// the ability to do searching by key. This makes compaction less usable,
	// but that simply cannot be avoided.

	if child == nil || trie.item != nil || child.item != nil {
		return trie
	}

Simple and quick mitigation as a backdoor for such scenario

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions