Skip to content

Commit

Permalink
Fix possible use after free bug
Browse files Browse the repository at this point in the history
  • Loading branch information
onli committed Dec 6, 2023
1 parent aef7e80 commit 9cbad81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/simImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ simImage::simImage()
blur = 0;
pid = PID_NONE;
lastWindow = 0;
// Task gets set to true when this simImage is connected to a currently open window
// and iff it is not a permanent starter
task = false;
}

Expand Down
10 changes: 5 additions & 5 deletions src/tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ static void tasks_window_closed (WnckScreen *screen, WnckWindow *window,callback
if (img->hasWindow(window)) {
img->removeWindow(window);
if (img->task && img->windowCount() == 0) {
// This can be safely deleted, it is not a starter and all windows are closed
delete img;
ImagesList->RemoveAt (i);
} else if (img->windowCount() == 0) {
// we need to fall back to the default image, if a starter
// we need to fall back to the default image, as it is a permanent starter
img->loadImage(img->img_link);
}

if (img->windowCount() > 0) {
} else if (img->windowCount() > 0) {
taskInfo ti;
ti.Init(img->getWindow());
if (img->task) {
// starters still have their own image we prefer to use
// starters still have their own image we prefer to use, so we only do
// this for the non-starters
img->img = ti.icon.ConvertToImage();
}
}
Expand Down

0 comments on commit 9cbad81

Please sign in to comment.