skia2/gm
herb c1e97b372e Fix uninitialized memory bug in the SkGlyphCache.
The core of the problem is that the system is asked to lookup the metrics for a character with id == 0. This causes a hit in the fCharToGlyphHash matching the sentinel glyph. This happens because fCharToGlpyhHash is initialized with all zeros, therefore, the fID is zero matching the char with id == 0. The fAdvanceX field of the sentinel glyph is in fact not initialized.

The bigger question is now did a zero character get passed to getUnicharMetrics?

The breaking code is basically as follows:
wchar_t glyph = L'S';
paint.measureText(&glyph, 2);

This get mischaracterized as a utf8 string instead of a utf16(?) string. Because of the little endian ordering, this is the character string 'L' '\0'. Since the size of the original string is two bytes (but a single character) the '\0' is treated as its own character and past to getUnicharMetrics.

TEST:
On windows failed using DrMemory. With this change does not fail.

BUG=463204

Review URL: https://codereview.chromium.org/977063002
2015-03-05 11:51:11 -08:00
..
aaclip.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
aarectmodes.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
addarc.cpp add gm for path-arcs, and catch degenerate arc in conic-case 2015-02-17 11:43:14 -08:00
alphagradients.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
arcofzorro.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
arithmode.cpp use platform-independent font for gm 2014-06-23 11:25:00 -07:00
astcbitmap.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
beziereffects.cpp Move clip off of draw target 2015-02-23 14:44:58 -08:00
beziers.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
bigblurs.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
bigmatrix.cpp Add always-threaded SkRecord quilt tests. 2014-07-07 10:41:04 -07:00
bigtext.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
bitmapcopy.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
bitmapfilters.cpp use platform-independent font for gm 2014-06-23 11:25:00 -07:00
bitmappremul.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
bitmaprect.cpp fix gm to not rely on SkColor's swizzle == SkPMColor's 2015-01-27 07:26:51 -08:00
bitmaprecttest.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
bitmapscroll.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
bitmapshader.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
bitmapsource.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
bleed.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
blurcircles.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
blurquickreject.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
blurrect.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
blurroundrect.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
blurs.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
cgm.c disable using codecs until that can work in chrome 2014-12-25 20:41:13 -08:00
cgms.cpp more c 2014-11-24 19:11:48 -08:00
circles.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
circularclips.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
clip_strokerect.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
clipdrawdraw.cpp Clean up clipping code a bit 2015-02-10 08:16:55 -08:00
clippedbitmapshaders.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
cmykjpeg.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
colorcube.cpp Adding 3D lut color filter 2014-10-09 05:27:23 -07:00
coloremoji.cpp Add sbix font to coloremoji gm. 2015-01-26 14:08:52 -08:00
colorfilterimagefilter.cpp Factory methods for heap-allocated SkImageFilter objects. 2014-03-10 10:51:58 +00:00
colorfilters.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
colormatrix.cpp Cleanup: Get rid of make_isize() function from gm.h. 2014-06-09 23:59:03 -07:00
colortype.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
colortypexfermode.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
colorwheel.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
complexclip2.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
complexclip3.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
complexclip.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
composeshader.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
concavepaths.cpp Tessellating GPU path renderer. 2015-02-26 06:58:17 -08:00
conicpaths.cpp Fix to check for inf when generating quadratic points 2015-02-25 06:41:47 -08:00
convexpaths.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
convexpolyclip.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
convexpolyeffect.cpp GMs now use batch 2015-02-11 13:45:51 -08:00
copyTo4444.cpp Cleanup usage of GetResourcePath() after commit bcbc1788b4. 2014-07-01 12:35:49 -07:00
cubicpaths.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
dashcubics.cpp break out of cubic stroker loop on degenerate case 2015-02-23 12:47:03 -08:00
dashing.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
dcshader.cpp Add standard way to indicate GM is GPU-only. 2015-01-31 07:51:14 -08:00
degeneratesegments.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
dftext.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
discard.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
displacement.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
distantclip.cpp Change SkPicture::draw to playback 2014-09-04 08:42:50 -07:00
downsamplebitmap.cpp GM: showmiplevels handles bitmap memory in a nicer way. 2015-02-24 09:25:09 -08:00
drawbitmaprect.cpp add newImage API 2015-01-23 05:58:07 -08:00
drawlooper.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
dropshadowimagefilter.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
drrect.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
dstreadshuffle.cpp dstread gm 2015-01-28 11:08:01 -08:00
emboss.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
emptypath.cpp There can be only one (SkRandom)! 2014-12-15 12:54:51 -08:00
etc1bitmap.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
extractbitmap.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
factory.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
fatpathfill.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
filltypes.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
filltypespersp.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
filterbitmap.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
filterfastbounds.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
filterindiabox.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
fontcache.cpp Fix uninitialized memory bug in the SkGlyphCache. 2015-03-05 11:51:11 -08:00
fontmgr.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
fontscaler.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
gammatext.cpp Revert of disable gammatext gm for a while, looking for other flakes (patchset #1 id:1 of https://codereview.chromium.org/725303002/) 2015-02-19 07:45:14 -08:00
getpostextpath.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
giantbitmap.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
glyph_pos_align.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
glyph_pos.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
gm_expectations.h In Android framework, make tools depend on jsoncpp 2014-06-18 10:31:40 -07:00
gm.cpp add SkAnimTimer, SPACE = pause/resume, ESP = stop 2015-02-02 12:55:02 -08:00
gm.h add SkAnimTimer, SPACE = pause/resume, ESP = stop 2015-02-02 12:55:02 -08:00
gradient_matrix.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
gradientDirtyLaundry.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
gradients_2pt_conical.cpp Add always-threaded SkRecord quilt tests. 2014-07-07 10:41:04 -07:00
gradients_no_texture.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
gradients.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
gradtext.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
grayscalejpg.cpp Remove PDF JPEG shortcut, since it fails on grayscale JPEGs. 2014-12-02 06:37:21 -08:00
hairlines.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
hairmodes.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
hittestpath.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
image.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
image.h check-point for image/surface work 2012-07-29 20:38:16 +00:00
imagealphathreshold.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
imageblur2.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
imageblur.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
imageblurtiled.cpp Add standard fonts to all GMs. 2014-07-31 08:58:44 -04:00
imagefiltersbase.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
imagefiltersclipped.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
imagefilterscropexpand.cpp Adding an option to render only the shadow in SkDropShadowImageFilter 2014-10-23 13:59:52 -07:00
imagefilterscropped.cpp Add missing SK_OVERRIDE 2015-02-02 12:08:18 -08:00
imagefiltersgraph.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
imagefiltersscaled.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
imagemagnifier.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
imageresizetiled.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
internal_links.cpp Add standard fonts to all GMs. 2014-07-31 08:58:44 -04:00
inversepaths.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
lcdtext.cpp remove dead code (covered by surfaceprops) 2015-02-23 07:37:40 -08:00
lerpmode.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
lighting.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
linepaths.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
lumafilter.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
matrixconvolution.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
matriximagefilter.cpp Cleanup: Get rid of make_isize() function from gm.h. 2014-06-09 23:59:03 -07:00
megalooper.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
mipmap.cpp gm to illustrate mipmap layer choice 2015-02-19 11:39:46 -08:00
mixedxfermodes.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
modecolorfilters.cpp Cleanup: Get rid of make_isize() function from gm.h. 2014-06-09 23:59:03 -07:00
morphology.cpp Add standard fonts to all GMs. 2014-07-31 08:58:44 -04:00
multipicturedraw.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
nested.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
ninepatchstretch.cpp Add always-threaded SkRecord quilt tests. 2014-07-07 10:41:04 -07:00
nonclosedpaths.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
offsetimagefilter.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
ovals.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
patch.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
patchgrid.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
patheffects.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
pathfill.cpp update sampleapp for stroking experiment 2015-02-18 10:56:00 -08:00
pathinterior.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
pathopsinverse.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
pathopsskpclip.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
pathreverse.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
peekpixels.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
perlinnoise.cpp Fix tiled perlin noise. 2014-06-12 11:24:20 -07:00
picture.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
pictureimagefilter.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
pictureshader.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
pictureshadertile.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
points.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
poly2poly.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
polygons.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
quadpaths.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
recordopts.cpp Fix Windows build 2015-01-26 05:39:26 -08:00
rects.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
repeated_bitmap.cpp PDF: Add (low-memory) SkPDFBitmap class 2015-02-18 11:29:57 -08:00
resizeimagefilter.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
roundrects.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
rrect.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
rrects.cpp Move clip off of draw target 2015-02-23 14:44:58 -08:00
samplerstress.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
selftest.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
shaderbounds.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
shadertext2.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
shadertext3.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
shadertext.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
shadows.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
shallowgradient.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
simpleaaclip.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
SkAnimTimer.h add SkAnimTimer, SPACE = pause/resume, ESP = stop 2015-02-02 12:55:02 -08:00
skbug1719.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
smallarc.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
smallimage.cpp work in progress 2014-12-02 14:01:46 -08:00
spritebitmap.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
srcmode.cpp Add standard fonts to all GMs. 2014-07-31 08:58:44 -04:00
stlouisarch.cpp gm to test hairlines which fill RenderTarget 2015-02-19 10:25:21 -08:00
stringart.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
strokefill.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
strokerect.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
strokerects.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
strokes.cpp fuzzer fixes 2015-02-25 09:04:04 -08:00
stroketext.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
surface.cpp Require budget decision when creating a RenderTarget SkSurface. 2015-01-16 07:32:33 -08:00
system_preferences_default.cpp Set LCD font smoothing to "medium" for gm on Mac, regardless of system settings 2012-02-14 14:53:59 +00:00
system_preferences_mac.mm gm: Include system_preferences.h in mac file. 2012-09-26 15:41:42 +00:00
system_preferences.h Set LCD font smoothing to "medium" for gm on Mac, regardless of system settings 2012-02-14 14:53:59 +00:00
tablecolorfilter.cpp change colorfilter to return an array of frag processors 2015-03-03 06:41:45 -08:00
tallstretchedbitmaps.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
techtalk1.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
testimagefilters.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
texdata.cpp I'd really like to land this before the branch so speedy reviews are appreciated. 2015-02-25 13:19:48 -08:00
textblob.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
textblobshader.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
texteffects.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
texturedomaineffect.cpp Move clip off of draw target 2015-02-23 14:44:58 -08:00
thinrects.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
thinstrokedrects.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
tiledscaledbitmap.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
tileimagefilter.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
tilemodes_scaled.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
tilemodes.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
tinybitmap.cpp Cleanup: Get rid of make_isize() function from gm.h. 2014-06-09 23:59:03 -07:00
transparency.cpp Modify transparency_check GM to always tile correctly. 2015-01-08 12:11:42 -08:00
twopointradial.cpp Add standard fonts to all GMs. 2014-07-31 08:58:44 -04:00
typeface.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
variedtext.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
vertices.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
verttext2.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
verttext.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
verylargebitmap.cpp remove unused GM flags 2015-01-23 11:07:08 -08:00
xfermodeimagefilter.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
xfermodes2.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
xfermodes3.cpp Require budget decision when creating a RenderTarget SkSurface. 2015-01-16 07:32:33 -08:00
xfermodes.cpp Fix up all the easy virtual ... SK_OVERRIDE cases. 2015-01-09 10:06:40 -08:00
yuvtorgbeffect.cpp Move clip off of draw target 2015-02-23 14:44:58 -08:00