catch uninitialized use of adid

This commit is contained in:
Felix Kratz 2021-12-19 19:26:54 +01:00
parent 62357cc8b6
commit a93c7ea50d
3 changed files with 3 additions and 1 deletions

View file

@ -26,7 +26,7 @@ profile: BUILD_FLAGS=-std=c99 -Wall -DDEBUG -g -Ofast -fvisibility=hidden
profile: clean $(x86_BINS)
debug: BUILD_FLAGS=-std=c99 -Wall -DDEBUG -fsanitize=address -fsanitize=undefined -g -O0 -fvisibility=hidden
debug: clean $(x86_BINS)
debug: clean $(ARM_BINS)
update: clean $(UNIVERSAL_BINS)
rm /usr/local/bin/sketchybar

View file

@ -304,6 +304,7 @@ CGRect bar_item_construct_bounding_rect(struct bar_item* bar_item) {
}
void bar_item_set_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid, CGPoint bar_origin, uint32_t height) {
if (adid <= 0) return;
if (bar_item->num_rects < adid) {
bar_item->bounding_rects = (CGRect**) realloc(bar_item->bounding_rects, sizeof(CGRect*) * adid);
memset(bar_item->bounding_rects + bar_item->num_rects, 0, sizeof(CGRect*) * (adid - bar_item->num_rects));

View file

@ -12,6 +12,7 @@ void popup_init(struct popup* popup) {
popup->frame.origin = (CGPoint){0,0};
popup->anchor = (CGPoint){100, 100};
popup->y_offset = 0;
popup->adid = 0;
popup->num_items = 0;
popup->cell_size = 30;