[Scummvm-git-logs] scummvm master -> 24cec3cd1b23a9617f4facfdc3eee6ec7d759c86
criezy
noreply at scummvm.org
Sun Feb 27 20:11:12 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
24cec3cd1b GUI: Fix use after free of surface in GridWidget
Commit: 24cec3cd1b23a9617f4facfdc3eee6ec7d759c86
https://github.com/scummvm/scummvm/commit/24cec3cd1b23a9617f4facfdc3eee6ec7d759c86
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-02-27T20:11:02Z
Commit Message:
GUI: Fix use after free of surface in GridWidget
This happened after calling scaleGfx if the original surface was
already at the correct size. In such a case scaleGfx returns the
original surface, so it should not be freed.
Changed paths:
gui/widgets/grid.cpp
diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index c8ba3605e7a..50801511f61 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -584,8 +584,10 @@ void GridWidget::reloadThumbnails() {
if (surf) {
const Graphics::ManagedSurface *scSurf(scaleGfx(surf, _thumbnailWidth, 512, true));
_loadedSurfaces[entry->thumbPath] = scSurf;
- surf->free();
- delete surf;
+ if (surf != scSurf) {
+ surf->free();
+ delete surf;
+ }
} else {
_loadedSurfaces[entry->thumbPath] = nullptr;
}
@@ -614,8 +616,10 @@ void GridWidget::loadPlatformIcons() {
if (gfx) {
const Graphics::ManagedSurface *scGfx = scaleGfx(gfx, _platformIconWidth, _platformIconHeight, true);
_platformIcons[l->id] = scGfx;
- gfx->free();
- delete gfx;
+ if (gfx != scGfx) {
+ gfx->free();
+ delete gfx;
+ }
} else {
_platformIcons[l->id] = nullptr;
}
More information about the Scummvm-git-logs
mailing list