From 1487a93e46bafb4ee7beb63e59b90265f0ae1fd3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 12 Jun 2014 09:06:35 +0200 Subject: Fix a possible use after free Found by coverity. The cachedIcon can be deleted when being inserted into the icon cache (in QCache::insert). So copy it to icon before trying to insert it into the cache. Change-Id: I5ed13c0c7ecb8f8f13285ca5d06237493dbea479 Reviewed-by: Laszlo Agocs --- src/gui/image/qicon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index adbd21a8a0..6f6bf158c8 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1173,8 +1173,8 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) QIconEngine * const engine = platformTheme ? platformTheme->createIconEngine(name) : new QIconLoaderEngine(name); QIcon *cachedIcon = new QIcon(engine); - qtIconCache()->insert(name, cachedIcon); icon = *cachedIcon; + qtIconCache()->insert(name, cachedIcon); } // Note the qapp check is to allow lazy loading of static icons -- cgit v1.2.3