mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-26 21:30:17 +00:00
fix memory leak for currently undocumented space image capture
This commit is contained in:
parent
7fa534b415
commit
89af3cca83
3 changed files with 12 additions and 5 deletions
|
@ -304,9 +304,9 @@ static void bar_calculate_bounds_top_bottom(struct bar* bar) {
|
|||
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
|
||||
struct bar_item* bar_item = g_bar_manager.bar_items[i];
|
||||
|
||||
if (!bar_draws_item(bar, bar_item)
|
||||
|| bar_item->type != BAR_COMPONENT_GROUP
|
||||
|| bar_item->position == POSITION_POPUP ) {
|
||||
if (bar_item->type != BAR_COMPONENT_GROUP
|
||||
|| bar_item->position == POSITION_POPUP
|
||||
|| !bar_draws_item(bar, bar_item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ bool image_set_enabled(struct image* image, bool enabled) {
|
|||
|
||||
bool image_load(struct image* image, char* path, FILE* rsp) {
|
||||
char* app = string_copy(path);
|
||||
if (image->path) free(image->path);
|
||||
image->path = string_copy(path);
|
||||
char* res_path = resolve_path(path);
|
||||
CGImageRef new_image_ref = NULL;
|
||||
|
@ -62,7 +63,12 @@ bool image_load(struct image* image, char* path, FILE* rsp) {
|
|||
|
||||
if (data_provider) CFRelease(data_provider);
|
||||
}
|
||||
else {
|
||||
else if (strlen(res_path) == 0) {
|
||||
image_destroy(image);
|
||||
free(res_path);
|
||||
free(app);
|
||||
return false;
|
||||
} else {
|
||||
respond(rsp, "[!] Image: File '%s' not found\n", res_path);
|
||||
free(res_path);
|
||||
free(app);
|
||||
|
|
|
@ -567,8 +567,9 @@ static inline CGImageRef space_capture(uint32_t sid) {
|
|||
CFArrayRef result = SLSHWCaptureSpace(g_connection, dsid, 0);
|
||||
uint32_t count = CFArrayGetCount(result);
|
||||
if (count > 0) {
|
||||
image = (CGImageRef)CFArrayGetValueAtIndex(result, 0);
|
||||
image = (CGImageRef)CFRetain(CFArrayGetValueAtIndex(result, 0));
|
||||
}
|
||||
CFRelease(result);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue