Project

General

Profile

Bug #5478 » 0001-Fix-use-after-free-with-LostPassword-Widget.patch

Bruce Toll, 01/04/2017 07:56 AM

View differences:

src/Wt/Auth/LostPasswordWidget
private:
AbstractUserDatabase& users_;
const AuthService& baseAuth_;
void deleteBox(WMessageBox *box);
std::unique_ptr<WMessageBox> box_;
};
}
src/Wt/Auth/LostPasswordWidget.C
baseAuth_.lostPassword(email->valueText().toUTF8(), users_);
cancel();
std::unique_ptr<WMessageBox> box
(new WMessageBox(tr("Wt.Auth.lost-password"), tr("Wt.Auth.mail-sent"),
Icon::None, StandardButton::Ok));
box->show();
box->buttonClicked().connect(std::bind(&LostPasswordWidget::deleteBox, this, box.get()));
addChild(std::move(box));
}
void LostPasswordWidget::deleteBox(WMessageBox *box)
{
removeChild(box);
// hide enclosing dialog
WWidget *w = parent();
while (w && !dynamic_cast<WDialog *>(w))
w = w->parent();
if (w)
w->hide();
box_ = std::make_unique<WMessageBox>
(tr("Wt.Auth.lost-password"), tr("Wt.Auth.mail-sent"),
Icon::None, StandardButton::Ok);
box_->show();
box_->buttonClicked().connect([this] () {
box_.reset();
removeFromParent();
});
}
void LostPasswordWidget::cancel()
(2-2/2)