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

Side by Side Diff: src/cmap.cc

Issue 10913058: [OTS] cmap ParseFormat4() should check the first segment (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 3 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cmap.h" 5 #include "cmap.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 // The last range must end at 0xffff 207 // The last range must end at 0xffff
208 if (ranges[segcount - 1].end_range != 0xffff) { 208 if (ranges[segcount - 1].end_range != 0xffff) {
209 return OTS_FAILURE(); 209 return OTS_FAILURE();
210 } 210 }
211 211
212 // A format 4 CMAP subtable is complex. To be safe we simulate a lookup of 212 // A format 4 CMAP subtable is complex. To be safe we simulate a lookup of
213 // each code-point defined in the table and make sure that they are all valid 213 // each code-point defined in the table and make sure that they are all valid
214 // glyphs and that we don't access anything out-of-bounds. 214 // glyphs and that we don't access anything out-of-bounds.
215 for (unsigned i = 1; i < segcount; ++i) { 215 for (unsigned i = 0; i < segcount; ++i) {
agl 2012/09/04 13:30:05 Was there a reason why we didn't check the 0-index
Yusuke Sato 2012/09/04 17:43:06 I guess this is just a careless mistake... Line 1
216 for (unsigned cp = ranges[i].start_range; cp <= ranges[i].end_range; ++cp) { 216 for (unsigned cp = ranges[i].start_range; cp <= ranges[i].end_range; ++cp) {
217 const uint16_t code_point = cp; 217 const uint16_t code_point = cp;
218 if (ranges[i].id_range_offset == 0) { 218 if (ranges[i].id_range_offset == 0) {
219 // this is explictly allowed to overflow in the spec 219 // this is explictly allowed to overflow in the spec
220 const uint16_t glyph = code_point + ranges[i].id_delta; 220 const uint16_t glyph = code_point + ranges[i].id_delta;
221 if (glyph >= num_glyphs) { 221 if (glyph >= num_glyphs) {
222 return OTS_FAILURE(); 222 return OTS_FAILURE();
223 } 223 }
224 } else { 224 } else {
225 const uint16_t range_delta = code_point - ranges[i].start_range; 225 const uint16_t range_delta = code_point - ranges[i].start_range;
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 out->RestoreChecksum(saved_checksum); 1067 out->RestoreChecksum(saved_checksum);
1068 1068
1069 return true; 1069 return true;
1070 } 1070 }
1071 1071
1072 void ots_cmap_free(OpenTypeFile *file) { 1072 void ots_cmap_free(OpenTypeFile *file) {
1073 delete file->cmap; 1073 delete file->cmap;
1074 } 1074 }
1075 1075
1076 } // namespace ots 1076 } // namespace ots
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698