mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Fix possible memory leak setting invalid preference when loading a BoolPrefWidget from an XML file
Reported in #2782
This commit is contained in:
parent
89f8e6f275
commit
6157b004e4
@ -39,6 +39,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -202,9 +203,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
if (!widget) {
|
||||
// Automatic bind <check> widget with bool preference option
|
||||
if (pref) {
|
||||
auto prefWidget = new BoolPrefWidget<CheckBox>("");
|
||||
std::unique_ptr<BoolPrefWidget<CheckBox>> prefWidget(
|
||||
new BoolPrefWidget<CheckBox>(""));
|
||||
prefWidget->setPref(pref);
|
||||
widget = prefWidget;
|
||||
widget = prefWidget.release();
|
||||
}
|
||||
else {
|
||||
widget = new CheckBox("");
|
||||
|
Loading…
x
Reference in New Issue
Block a user