File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/skia/cpp/api/recorder Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -246,10 +246,18 @@ class TextPathCmd : public Command {
246246
247247 // Get glyph widths
248248 int glyphsSize = static_cast <int >(ids);
249+
250+ // Validate glyph count
251+ if (glyphsSize > numGlyphIds) {
252+ throw std::runtime_error (
253+ " Glyph count mismatch: got " + std::to_string (glyphsSize) +
254+ " glyphs but expected " + std::to_string (numGlyphIds));
255+ }
256+
249257 std::vector<SkScalar> widthPtrs;
250258 widthPtrs.resize (glyphsSize);
251259 font->getWidthsBounds (
252- SkSpan (glyphIds.data (), numGlyphIds ),
260+ SkSpan (glyphIds.data (), glyphsSize ),
253261 SkSpan (static_cast <SkScalar *>(widthPtrs.data ()), widthPtrs.size ()),
254262 {},
255263 nullptr ); // TODO: Should we use paint somehow here?
@@ -260,7 +268,7 @@ class TextPathCmd : public Command {
260268 auto cont = meas.next ();
261269 auto dist = initialOffset;
262270
263- for (size_t i = 0 ; i < text. length () && cont != nullptr ; ++i) {
271+ for (int i = 0 ; i < glyphsSize && cont != nullptr ; ++i) {
264272 auto width = widthPtrs[i];
265273 dist += width / 2 ;
266274 if (dist > cont->length ()) {
You can’t perform that action at this time.
0 commit comments