diff options
author | Mårten Nordheim <[email protected]> | 2024-08-28 11:33:07 +0200 |
---|---|---|
committer | Mårten Nordheim <[email protected]> | 2024-08-28 19:01:40 +0200 |
commit | 5028ff12d61cfb5d50d9854ca0e00c4862de4685 (patch) | |
tree | 0082a51d3733617de87fbb47a381c99b2c8b7c3b | |
parent | 65fecd0c47d6ff39e8a728b0c6538d44f3aa00aa (diff) |
Font: Fix potential use-after-free
The detach() call might deallocate the d-ptr we already
cached in the Q_D call, so move the Q_D call to after
detach()ing.
Even if it was not deallocated, as long as it was previously
shared, we would assign to the wrong private.
Change-Id: I9643ad72a7c7934cba9807220a9cf6c53c66ab13
Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r-- | src/gui/text/qfontvariableaxis.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/gui/text/qfontvariableaxis.cpp b/src/gui/text/qfontvariableaxis.cpp index 79a05b3617e..dfce507afe3 100644 --- a/src/gui/text/qfontvariableaxis.cpp +++ b/src/gui/text/qfontvariableaxis.cpp @@ -81,10 +81,10 @@ QFont::Tag QFontVariableAxis::tag() const */ void QFontVariableAxis::setTag(QFont::Tag tag) { - Q_D(QFontVariableAxis); - if (d->tag == tag) + if (d_func()->tag == tag) return; detach(); + Q_D(QFontVariableAxis); d->tag = tag; } @@ -109,10 +109,10 @@ QString QFontVariableAxis::name() const */ void QFontVariableAxis::setName(const QString &name) { - Q_D(QFontVariableAxis); - if (d->name == name) + if (d_func()->name == name) return; detach(); + Q_D(QFontVariableAxis); d->name = name; } @@ -138,10 +138,10 @@ qreal QFontVariableAxis::minimumValue() const */ void QFontVariableAxis::setMinimumValue(qreal minimumValue) { - Q_D(QFontVariableAxis); - if (d->minimumValue == minimumValue) + if (d_func()->minimumValue == minimumValue) return; detach(); + Q_D(QFontVariableAxis); d->minimumValue = minimumValue; } @@ -167,10 +167,10 @@ qreal QFontVariableAxis::maximumValue() const */ void QFontVariableAxis::setMaximumValue(qreal maximumValue) { - Q_D(QFontVariableAxis); - if (d->maximumValue == maximumValue) + if (d_func()->maximumValue == maximumValue) return; detach(); + Q_D(QFontVariableAxis); d->maximumValue = maximumValue; } @@ -196,10 +196,10 @@ qreal QFontVariableAxis::defaultValue() const */ void QFontVariableAxis::setDefaultValue(qreal defaultValue) { - Q_D(QFontVariableAxis); - if (d->defaultValue == defaultValue) + if (d_func()->defaultValue == defaultValue) return; detach(); + Q_D(QFontVariableAxis); d->defaultValue = defaultValue; } |