42 lines
1.3 KiB
Diff
42 lines
1.3 KiB
Diff
# UNDF: UNDF-2026-000000880
|
|
--- a/common/objects.c
|
|
+++ b/common/objects.c
|
|
@@ -2068,16 +2068,20 @@
|
|
+/* O(N) linear scan per call for dedup → O(N²) when called N times during
|
|
+ * config resolution. Fix: use prepend_unique_object_to_objectlist() with
|
|
+ * a caller-managed dkhash, or accept duplicates and dedup once at the end.
|
|
+ *
|
|
+ * Minimal ABI-safe fix: convert pointer to string key for dkhash lookup.
|
|
+ * Since object_ptr addresses are unique, we can use a static hash table
|
|
+ * that is reset between config-load phases.
|
|
+ */
|
|
int add_object_to_objectlist(objectlist **list, void *object_ptr) {
|
|
- objectlist *temp_item = NULL;
|
|
objectlist *new_item = NULL;
|
|
+ static dkhash_table *seen = NULL;
|
|
+ char key[32];
|
|
|
|
if(list == NULL || object_ptr == NULL)
|
|
return ERROR;
|
|
|
|
- /* skip this object if its already in the list */
|
|
- for(temp_item = *list; temp_item; temp_item = temp_item->next) {
|
|
- if(temp_item->object_ptr == object_ptr)
|
|
- break;
|
|
- }
|
|
- if(temp_item)
|
|
+ if(seen == NULL)
|
|
+ seen = dkhash_create(1024);
|
|
+ snprintf(key, sizeof(key), "%p", object_ptr);
|
|
+ if(dkhash_get(seen, key, NULL) != NULL)
|
|
return OK;
|
|
|
|
/* allocate memory for a new list item */
|
|
@@ -2090,6 +2094,7 @@
|
|
/* add new item to head of list */
|
|
new_item->next = *list;
|
|
*list = new_item;
|
|
+ dkhash_insert(seen, strdup(key), NULL, new_item);
|
|
|
|
return OK;
|
|
}
|