Bug 966021 - Fix load_truetype_table in the cairo dwrite font backend. r=bas, a=lsblakk
authorJonathan Kew <jkew@mozilla.com>
Sat, 01 Feb 2014 09:24:58 +0000
changeset 176203 fd6042c0a6bdc67ad1fa62f146988494b4850424
parent 176202 2151d583a45cd86c3a08a2d0d85c945d15172e49
child 176204 9737529dc0e2158561d347cd22045435d22ce7cf
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, lsblakk
bugs966021
milestone28.0a2
Bug 966021 - Fix load_truetype_table in the cairo dwrite font backend. r=bas, a=lsblakk
gfx/cairo/cairo/src/cairo-dwrite-font.cpp
--- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
+++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
@@ -1047,20 +1047,22 @@ cairo_int_status_t
 				      &size,
 				      &tableContext,
 				      &exists);
 
     if (!exists) {
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
+    if (buffer && *length && (UINT32)offset < size) {
+        size = MIN(size - (UINT32)offset, *length);
+        memcpy(buffer, (const char*)data + offset, size);
+    }
     *length = size;
-    if (buffer) {
-	memcpy(buffer, data, size);
-    }
+
     if (tableContext) {
 	face->dwriteface->ReleaseFontTable(tableContext);
     }
     return (cairo_int_status_t)CAIRO_STATUS_SUCCESS;
 }
 
 // WIN32 Helper Functions
 cairo_font_face_t*