From 2bf77561966c87c0a410a743b2307d955e2135e9 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Thu, 20 Feb 2020 08:12:08 +0100 Subject: [PATCH] Avoid potential leak of memory pointed to by QTreeWidgetItem catItem --- src/frontends/qt/GuiLyXFiles.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontends/qt/GuiLyXFiles.cpp b/src/frontends/qt/GuiLyXFiles.cpp index 6a59e6eea3..096a390d64 100644 --- a/src/frontends/qt/GuiLyXFiles.cpp +++ b/src/frontends/qt/GuiLyXFiles.cpp @@ -418,8 +418,9 @@ void GuiLyXFiles::updateContents() qstring_to_ucs4(guiString(catsave.mid(catsave.indexOf('/') + 1))))); } cat = toqstr(translateIfPossible(qstring_to_ucs4(guiString(cat)))); - QTreeWidgetItem * catItem = new QTreeWidgetItem(); + QTreeWidgetItem * catItem; if (!cats.contains(cat)) { + catItem = new QTreeWidgetItem(); catItem->setText(0, cat); catItem->setFont(0, capfont); filesLW->insertTopLevelItem(0, catItem);