diff options
| author | Alexander Golubev <fatzer2@gmail.com> | 2026-03-18 13:35:30 +0300 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2026-03-18 13:53:58 +0300 |
| commit | a04969affec3486045cfc954bda59d1a3217e319 (patch) | |
| tree | adcc833faffba105c94b94b10e9a8a6e1e81e317 /src/kernel/tqscriptengine_x11.cpp | |
| parent | 6ec5d7ec4ff7cfbb52866b28c8b36e5ea3ee31d1 (diff) | |
| download | tqt-a04969affec3486045cfc954bda59d1a3217e319.tar.gz tqt-a04969affec3486045cfc954bda59d1a3217e319.zip | |
Fix infinite looping in TQTextEngine::shape()
With certain characters a loop inside TQTextEngine::shape() could
repeat forever because some script engines were requesting more memory
because of a mistake.
In particular this were observed with at least letters "ई" (U+0908,
DEVANAGARI LETTER II) and "ༀ" (U+0F00, TIBETAN SYLLABLE OM).
The problem was already solved in Qt somewhere between last Qt3 release
and first Qt4. But due to no public VCS is available it's impossible to
pinpoint an exact commit. This patch is heavily based on the Qt-4.3.5
code.
Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/tqt/issues/270
Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tdeutils/issues/93
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
Diffstat (limited to 'src/kernel/tqscriptengine_x11.cpp')
| -rw-r--r-- | src/kernel/tqscriptengine_x11.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/kernel/tqscriptengine_x11.cpp b/src/kernel/tqscriptengine_x11.cpp index 6d5429cb0..c54f6d6b1 100644 --- a/src/kernel/tqscriptengine_x11.cpp +++ b/src/kernel/tqscriptengine_x11.cpp @@ -69,12 +69,13 @@ static bool thaana_shape(TQShaperItem *item) if (openType && openType->supportsScript(item->script)) { openType->selectScript(TQFont::Thaana); + const int availableGlyphs = item->num_glyphs; if (item->font->stringToCMap(item->string->unicode()+item->from, item->length, item->glyphs, item->advances, &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) return false; heuristicSetGlyphAttributes(item); openType->shape(item); - return openType->positionAndAdd(item); + return openType->positionAndAdd(item, availableGlyphs); } #endif return basic_shape(item); @@ -1550,6 +1551,9 @@ static bool indic_shape_syllable(TQOpenType *openType, TQShaperItem *item, bool reph = i; } +#ifndef TQT_NO_XFTFREETYPE + const int availableGlyphs = item->num_glyphs; +#endif if (item->font->stringToCMap((const TQChar *)reordered.data(), len, item->glyphs, item->advances, &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) return false; @@ -1694,7 +1698,7 @@ static bool indic_shape_syllable(TQOpenType *openType, TQShaperItem *item, bool } } - if (!openType->positionAndAdd(item, false)) + if (!openType->positionAndAdd(item, availableGlyphs, false)) return false; if (control) { @@ -2056,6 +2060,9 @@ static bool tibetan_shape_syllable(TQOpenType *openType, TQShaperItem *item, boo str = (TQChar *)reordered.data(); } +#ifndef TQT_NO_XFTFREETYPE + const int availableGlyphs = item->num_glyphs; +#endif if (item->font->stringToCMap(str, len, item->glyphs, item->advances, &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) return false; @@ -2075,7 +2082,7 @@ static bool tibetan_shape_syllable(TQOpenType *openType, TQShaperItem *item, boo openType->selectScript(TQFont::Tibetan, tibetan_features); openType->shape(item); - if (!openType->positionAndAdd(item, false)) + if (!openType->positionAndAdd(item, availableGlyphs, false)) return false; } #endif @@ -2708,6 +2715,9 @@ static bool khmer_shape_syllable(TQOpenType *openType, TQShaperItem *item) } // switch } // for +#ifndef TQT_NO_XFTFREETYPE + const int availableGlyphs = item->num_glyphs; +#endif if (item->font->stringToCMap((const TQChar *)reordered, len, item->glyphs, item->advances, &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) return false; @@ -2745,7 +2755,7 @@ static bool khmer_shape_syllable(TQOpenType *openType, TQShaperItem *item) } openType->shape(item, where); - if (!openType->positionAndAdd(item, false)) + if (!openType->positionAndAdd(item, availableGlyphs, false)) return false; } else #endif @@ -3215,6 +3225,9 @@ static bool myanmar_shape_syllable(TQOpenType *openType, TQShaperItem *item, boo len += 2; } +#ifndef TQT_NO_XFTFREETYPE + const int availableGlyphs = item->num_glyphs; +#endif if (item->font->stringToCMap((const TQChar *)reordered, len, item->glyphs, item->advances, &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) return false; @@ -3252,7 +3265,7 @@ static bool myanmar_shape_syllable(TQOpenType *openType, TQShaperItem *item, boo } openType->shape(item, where); - if (!openType->positionAndAdd(item, false)) + if (!openType->positionAndAdd(item, availableGlyphs, false)) return false; } else #endif @@ -3499,6 +3512,9 @@ static bool hangul_shape_syllable(TQOpenType *openType, TQShaperItem *item) len = 1; } +#ifndef TQT_NO_XFTFREETYPE + const int availableGlyphs = item->num_glyphs; +#endif if (item->font->stringToCMap(ch, len, item->glyphs, item->advances, &item->num_glyphs, item->flags & TQTextEngine::RightToLeft) != TQFontEngine::NoError) return false; @@ -3519,7 +3535,7 @@ static bool hangul_shape_syllable(TQOpenType *openType, TQShaperItem *item) item->log_clusters = logClusters.data(); openType->shape(item); - if (!openType->positionAndAdd(item, false)) + if (!openType->positionAndAdd(item, availableGlyphs, false)) return false; } |
