diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index b730b415f0d..f4df95865d0 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -280,6 +280,13 @@ public: cancelPasswordEchoTimer(); m_echoMode = mode; m_passwordEchoEditing = false; + + // If this control is used for password input, we want to minimize + // the possibility of string reallocation not to leak (parts of) + // the password. + if (m_echoMode != QLineEdit::Normal) + m_text.reserve(30); + updateDisplayText(); }