Skip to content

Commit f25e1f2

Browse files
ttaylorrgitster
authored andcommitted
pack-bitmap-write.c: avoid uninitialized 'write_as' field
Prepare to free() memory associated with bitmapped_commit structs by zero'ing the 'write_as' field. In ideal cases, it is fine to do something like: for (i = 0; i < writer->selected_nr; i++) { struct bitmapped_commit *bc = &writer->selected[i]; if (bc->write_as != bc->bitmap) ewah_free(bc->write_as); ewah_free(bc->bitmap); } but if not all of the 'write_as' fields were populated (e.g., because the packing_data given does not form a reachability closure), then we may attempt to free uninitialized memory. Guard against this by preemptively zero'ing this field just in case. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9675b06 commit f25e1f2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

pack-bitmap-write.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static inline void push_bitmapped_commit(struct bitmap_writer *writer,
112112

113113
writer->selected[writer->selected_nr].commit = commit;
114114
writer->selected[writer->selected_nr].bitmap = NULL;
115+
writer->selected[writer->selected_nr].write_as = NULL;
115116
writer->selected[writer->selected_nr].flags = 0;
116117

117118
writer->selected_nr++;

0 commit comments

Comments
 (0)