From b8be5b4002bd6163851bbae397171ebbf632f02f Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 18 Mar 2020 05:36:49 +0300 Subject: [PATCH] HB-to-Qt bridge: get rid of stale/dubious safety checks these aren't needed for quite a long time already Change-Id: I3a5ce3199cee467d7dfba3c68256d214fee4d83c Reviewed-by: Lars Knoll --- src/gui/text/qharfbuzzng.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 695a190fd7..d802d1d58f 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -634,13 +634,14 @@ _hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) return hb_blob_get_empty(); char *buffer = static_cast(malloc(length)); - Q_CHECK_PTR(buffer); + if (q_check_ptr(buffer) == nullptr) + return nullptr; if (Q_UNLIKELY(!get_font_table(data->user_data, tag, reinterpret_cast(buffer), &length))) - length = 0; + return nullptr; return hb_blob_create(const_cast(buffer), length, - HB_MEMORY_MODE_READONLY, + HB_MEMORY_MODE_WRITABLE, buffer, free); } @@ -653,10 +654,6 @@ _hb_qt_face_create(QFontEngine *fe) data->get_font_table = fe->faceData.get_font_table; hb_face_t *face = hb_face_create_for_tables(_hb_qt_reference_table, (void *)data, free); - if (Q_UNLIKELY(hb_face_is_immutable(face))) { - hb_face_destroy(face); - return NULL; - } hb_face_set_index(face, fe->faceId().index); hb_face_set_upem(face, fe->emSquareSize().truncate()); @@ -667,8 +664,7 @@ _hb_qt_face_create(QFontEngine *fe) static void _hb_qt_face_release(void *user_data) { - if (Q_LIKELY(user_data)) - hb_face_destroy(static_cast(user_data)); + hb_face_destroy(static_cast(user_data)); } hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe) @@ -686,16 +682,9 @@ static inline hb_font_t * _hb_qt_font_create(QFontEngine *fe) { hb_face_t *face = hb_qt_face_get_for_engine(fe); - if (Q_UNLIKELY(!face)) - return NULL; hb_font_t *font = hb_font_create(face); - if (Q_UNLIKELY(hb_font_is_immutable(font))) { - hb_font_destroy(font); - return NULL; - } - const qreal y_ppem = fe->fontDef.pixelSize; const qreal x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100.0; @@ -711,8 +700,7 @@ _hb_qt_font_create(QFontEngine *fe) static void _hb_qt_font_release(void *user_data) { - if (Q_LIKELY(user_data)) - hb_font_destroy(static_cast(user_data)); + hb_font_destroy(static_cast(user_data)); } hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe)