summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-07-02 07:44:27 +0300
committerQt by Nokia <qt-info@nokia.com>2012-07-03 01:08:49 +0200
commit02aee5d174b0a1d0f925dc5c3243f77d0dc0c8c4 (patch)
tree54b9b1e6c1521de1fd9f07d22539d99c29990438 /src/plugins
parentd53f5db95366b550c23ef3684ef24d09d2d66fea (diff)
DirectWrite font engine: don't leak the font table buffer
Ideally, each TryGetFontTable() call sequence should be followed by the call to ReleaseFontTable() with the context value taken from the first TryGetFontTable() call, otherwise we'll leak the buffer allocated for the font table. Change-Id: I627bf0133b7f61798e82929723ccfb780ce9ee69 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
index b02686ceeb..568de480a0 100644
--- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp
@@ -254,6 +254,8 @@ QFixed QWindowsFontEngineDirectWrite::lineThickness() const
bool QWindowsFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, uint *length) const
{
+ bool ret = false;
+
if (m_directWriteFontFace) {
DWORD t = qbswap<quint32>(tag);
@@ -266,26 +268,22 @@ bool QWindowsFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, ui
);
if (SUCCEEDED(hr)) {
- if (!exists)
- return false;
-
- if (buffer == 0) {
- *length = tableSize;
- return true;
- } else if (*length < tableSize) {
- return false;
+ if (exists) {
+ if (!buffer) {
+ *length = tableSize;
+ ret = true;
+ } else if (*length >= tableSize) {
+ memcpy(buffer, tableData, tableSize);
+ ret = true;
+ }
}
-
- memcpy(buffer, tableData, tableSize);
m_directWriteFontFace->ReleaseFontTable(tableContext);
-
- return true;
} else {
qErrnoWarning("%s: TryGetFontTable failed", __FUNCTION__);
}
}
- return false;
+ return ret;
}
QFixed QWindowsFontEngineDirectWrite::emSquareSize() const