Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: src/ports/SkFontConfigInterface_direct.cpp

Issue 61913002: Adding error checks to SkRBuffer (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added doc Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009 Google Inc. 2 * Copyright 2009 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ 8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
9 9
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 35
36 SkASSERT(buffer.pos() == size); 36 SkASSERT(buffer.pos() == size);
37 } 37 }
38 return size; 38 return size;
39 } 39 }
40 40
41 size_t SkFontConfigInterface::FontIdentity::readFromMemory(const void* addr, 41 size_t SkFontConfigInterface::FontIdentity::readFromMemory(const void* addr,
42 size_t size) { 42 size_t size) {
43 SkRBuffer buffer(addr, size); 43 SkRBuffer buffer(addr, size);
44 44
45 fID = buffer.readU32(); 45 (void)buffer.readU32(&fID);
46 fTTCIndex = buffer.readU32(); 46 (void)buffer.readS32(&fTTCIndex);
47 size_t strLen = buffer.readU32(); 47 uint32_t strLen, weight, width;
48 int weight = buffer.readU32(); 48 (void)buffer.readU32(&strLen);
49 int width = buffer.readU32(); 49 (void)buffer.readU32(&weight);
50 SkFontStyle::Slant slant = (SkFontStyle::Slant)buffer.readU8(); 50 (void)buffer.readU32(&width);
51 uint8_t u8;
52 (void)buffer.readU8(&u8);
53 SkFontStyle::Slant slant = (SkFontStyle::Slant)u8;
51 fStyle = SkFontStyle(weight, width, slant); 54 fStyle = SkFontStyle(weight, width, slant);
52 fString.resize(strLen); 55 fString.resize(strLen);
53 buffer.read(fString.writable_str(), strLen); 56 (void)buffer.read(fString.writable_str(), strLen);
54 buffer.skipToAlign4(); 57 buffer.skipToAlign4();
55 58
56 return buffer.pos(); // the actual number of bytes read 59 return buffer.pos(); // the actual number of bytes read
57 } 60 }
58 61
59 #ifdef SK_DEBUG 62 #ifdef SK_DEBUG
60 static void make_iden(SkFontConfigInterface::FontIdentity* iden) { 63 static void make_iden(SkFontConfigInterface::FontIdentity* iden) {
61 iden->fID = 10; 64 iden->fID = 10;
62 iden->fTTCIndex = 2; 65 iden->fTTCIndex = 2;
63 iden->fString.set("Hello world"); 66 iden->fString.set("Hello world");
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 *trimmedMatches.append() = match[i]; 725 *trimmedMatches.append() = match[i];
723 } 726 }
724 } 727 }
725 728
726 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, 729 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC,
727 (trimmedMatches.begin(), 730 (trimmedMatches.begin(),
728 trimmedMatches.count())); 731 trimmedMatches.count()));
729 #endif 732 #endif
730 return false; 733 return false;
731 } 734 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698