Skip to content

Commit bb0e4c5

Browse files
committed
Fix -Werror=maybe-uninitialized warning
GCC with AddressSanitizer reports that pathp in map_insert() may be used uninitialized: src/map.c:593:15: error: pathp may be used uninitialized 593 | for (pathp--; (uintptr_t) pathp >= (uintptr_t) path; pathp--) While the program logic ensures pathp is always initialized through rb_insert_unique() before use, static analysis cannot prove this due to the pointer-to-pointer assignment pattern. Initialize to NULL to satisfy the compiler and improve defensive programming.
1 parent 9a33410 commit bb0e4c5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ bool map_insert(map_t obj, const void *key, const void *val)
572572
return false;
573573

574574
rb_path_entry_t path[RB_MAX_DEPTH];
575-
rb_path_entry_t *pathp;
575+
rb_path_entry_t *pathp = NULL;
576576

577577
/* Single traversal to check existence and get insertion point */
578578
const map_node_t *existing = rb_insert_unique(obj, key, path, &pathp);

0 commit comments

Comments
 (0)