Skip to content

UTIL: diff_string_lists() optimization#8450

Draft
alexey-tikhonov wants to merge 1 commit intoSSSD:masterfrom
alexey-tikhonov:initgr-loops
Draft

UTIL: diff_string_lists() optimization#8450
alexey-tikhonov wants to merge 1 commit intoSSSD:masterfrom
alexey-tikhonov:initgr-loops

Conversation

@alexey-tikhonov
Copy link
Member

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant optimization to the diff_string_lists function. The changes effectively reduce memory allocations by avoiding talloc_strdup when building the initial hash table and by pre-allocating the result arrays instead of using talloc_realloc inside loops.

However, I've found a critical issue where the return value of talloc_realloc is not checked when shrinking the result arrays. This can lead to silent failures on memory allocation errors, where the function would return EOK but with a NULL list, potentially causing NULL pointer dereferences in calling code. I've added comments with suggestions to fix this.

@alexey-tikhonov alexey-tikhonov added the Performance Performance related patches label Feb 19, 2026
 - don't copy string to use as keys
 - don't realloc inside a loop
 - don't use `hash_keys()` to avoid data copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-sssd-2-9 Performance Performance related patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant