Fix undefined behavior in DirectWrite GDI compatible metrics.
GetGdiCompatibleGlyphMetrics checks the matrix passed to it.
If the matrix has any NaNs or INFs or otherwise looks bad, it returns
E_INVALIDARG and so the advances will be zero.
BUG=skia:2579
R=reed@google.com
Review URL: https://codereview.chromium.org/298863002
git-svn-id: http://skia.googlecode.com/svn/trunk@14829 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp
index 431eeac..e024b46 100644
--- a/src/ports/SkFontHost_win_dw.cpp
+++ b/src/ports/SkFontHost_win_dw.cpp
@@ -801,6 +801,8 @@
fGsA.m12 = SkScalarToFloat(GsA.get(SkMatrix::kMSkewY)); // This should be ~0.
fGsA.m21 = SkScalarToFloat(GsA.get(SkMatrix::kMSkewX));
fGsA.m22 = SkScalarToFloat(GsA.get(SkMatrix::kMScaleY));
+ fGsA.dx = 0;
+ fGsA.dy = 0;
// fG_inv is G inverse, which is fairly simple since G is 2x2 rotational.
fG_inv.setAll(G.get(SkMatrix::kMScaleX), -G.get(SkMatrix::kMSkewX), G.get(SkMatrix::kMTransX),
diff --git a/src/utils/win/SkHRESULT.cpp b/src/utils/win/SkHRESULT.cpp
index 111cb76..495f074 100644
--- a/src/utils/win/SkHRESULT.cpp
+++ b/src/utils/win/SkHRESULT.cpp
@@ -9,10 +9,11 @@
#include "SkHRESULT.h"
-void SkTraceHR(const char* file, unsigned long line,
- HRESULT hr, const char* msg) {
- SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg)));
- SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr));
+void SkTraceHR(const char* file, unsigned long line, HRESULT hr, const char* msg) {
+ if (NULL != msg) {
+ SkDebugf("%s\n", msg);
+ }
+ SkDebugf("%s(%lu) : error 0x%x: ", file, line, hr);
LPSTR errorText = NULL;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
@@ -27,9 +28,9 @@
);
if (NULL == errorText) {
- SkDEBUGF(("<unknown>\n"));
+ SkDebugf("<unknown>\n");
} else {
- SkDEBUGF(("%s", errorText));
+ SkDebugf("%s", errorText);
LocalFree(errorText);
errorText = NULL;
}