Skip to content

Commit

Permalink
catch zero pointer assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKratz committed Aug 30, 2021
1 parent 17144d3 commit 52cb67c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bar_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ void bar_item_update_component(struct bar_item* bar_item, uint32_t did, uint32_t
}

void bar_item_set_name(struct bar_item* bar_item, char* name) {
if (!name) return;
if (name != bar_item->name && !bar_item->name) {
free(bar_item->name);
}
bar_item->name = name;
}

void bar_item_set_script(struct bar_item* bar_item, char* script) {
if (!script) return;
if (script != bar_item->script && !bar_item->script)
free(bar_item->script);
if (bar_item->cache_scripts && file_exists(resolve_path(script)))
Expand All @@ -94,6 +96,7 @@ void bar_item_set_script(struct bar_item* bar_item, char* script) {
}

void bar_item_set_click_script(struct bar_item* bar_item, char* script) {
if (!script) return;
if (script != bar_item->on_click_script && !bar_item->on_click_script)
free(bar_item->on_click_script);
if (bar_item->cache_scripts && file_exists(resolve_path(script)))
Expand All @@ -117,6 +120,7 @@ void bar_item_set_icon_color(struct bar_item* bar_item, uint32_t color) {
}

void bar_item_set_label(struct bar_item* bar_item, char* label) {
if (!label) return;
if (bar_item->label_line.line)
bar_destroy_line(bar_item->label_line);
if (label != bar_item->label && !bar_item->label)
Expand All @@ -130,6 +134,7 @@ void bar_item_set_label_color(struct bar_item* bar_item, uint32_t color) {
bar_item_set_label(bar_item, bar_item->label);
}
void bar_item_set_icon_font(struct bar_item* bar_item, char *font_string) {
if (!font_string) return;
if (bar_item->icon_font)
CFRelease(bar_item->icon_font);

Expand All @@ -138,6 +143,7 @@ void bar_item_set_icon_font(struct bar_item* bar_item, char *font_string) {
}

void bar_item_set_label_font(struct bar_item* bar_item, char *font_string) {
if (!font_string) return;
if (bar_item->label_font)
CFRelease(bar_item->label_font);

Expand Down

0 comments on commit 52cb67c

Please sign in to comment.