OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 1998-2004 David Turner and Werner Lemberg | 2 * Copyright © 1998-2004 David Turner and Werner Lemberg |
3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. | 3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc. |
4 * Copyright © 2011,2012 Google, Inc. | 4 * Copyright © 2011,2012 Google, Inc. |
5 * | 5 * |
6 * This is part of HarfBuzz, a text shaping library. | 6 * This is part of HarfBuzz, a text shaping library. |
7 * | 7 * |
8 * Permission is hereby granted, without written agreement and without | 8 * Permission is hereby granted, without written agreement and without |
9 * license or royalty fees, to use, copy, modify, and distribute this | 9 * license or royalty fees, to use, copy, modify, and distribute this |
10 * software and its documentation for any purpose, provided that the | 10 * software and its documentation for any purpose, provided that the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 * passed hb_shape(), and after shaping they hold the output glyphs. | 45 * passed hb_shape(), and after shaping they hold the output glyphs. |
46 **/ | 46 **/ |
47 | 47 |
48 /** | 48 /** |
49 * hb_segment_properties_equal: | 49 * hb_segment_properties_equal: |
50 * @a: first #hb_segment_properties_t to compare. | 50 * @a: first #hb_segment_properties_t to compare. |
51 * @b: second #hb_segment_properties_t to compare. | 51 * @b: second #hb_segment_properties_t to compare. |
52 * | 52 * |
53 * Checks the equality of two #hb_segment_properties_t's. | 53 * Checks the equality of two #hb_segment_properties_t's. |
54 * | 54 * |
55 * Return value: (transfer full): | 55 * Return value: |
56 * %true if all properties of @a equal those of @b, false otherwise. | 56 * %true if all properties of @a equal those of @b, false otherwise. |
57 * | 57 * |
58 * Since: 0.9.7 | 58 * Since: 0.9.7 |
59 **/ | 59 **/ |
60 hb_bool_t | 60 hb_bool_t |
61 hb_segment_properties_equal (const hb_segment_properties_t *a, | 61 hb_segment_properties_equal (const hb_segment_properties_t *a, |
62 const hb_segment_properties_t *b) | 62 const hb_segment_properties_t *b) |
63 { | 63 { |
64 return a->direction == b->direction && | 64 return a->direction == b->direction && |
65 a->script == b->script && | 65 a->script == b->script && |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return true; | 176 return true; |
177 } | 177 } |
178 | 178 |
179 bool | 179 bool |
180 hb_buffer_t::shift_forward (unsigned int count) | 180 hb_buffer_t::shift_forward (unsigned int count) |
181 { | 181 { |
182 assert (have_output); | 182 assert (have_output); |
183 if (unlikely (!ensure (len + count))) return false; | 183 if (unlikely (!ensure (len + count))) return false; |
184 | 184 |
185 memmove (info + idx + count, info + idx, (len - idx) * sizeof (info[0])); | 185 memmove (info + idx + count, info + idx, (len - idx) * sizeof (info[0])); |
| 186 if (idx + count > len) |
| 187 { |
| 188 /* Under memory failure we might expose this area. At least |
| 189 * clean it up. Oh well... */ |
| 190 memset (info + len, 0, (idx + count - len) * sizeof (info[0])); |
| 191 } |
186 len += count; | 192 len += count; |
187 idx += count; | 193 idx += count; |
188 | 194 |
189 return true; | 195 return true; |
190 } | 196 } |
191 | 197 |
192 hb_buffer_t::scratch_buffer_t * | 198 hb_buffer_t::scratch_buffer_t * |
193 hb_buffer_t::get_scratch_buffer (unsigned int *size) | 199 hb_buffer_t::get_scratch_buffer (unsigned int *size) |
194 { | 200 { |
195 have_output = false; | 201 have_output = false; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 425 |
420 memmove (out_info + out_len, info + idx, count * sizeof (out_info[0])); | 426 memmove (out_info + out_len, info + idx, count * sizeof (out_info[0])); |
421 idx += count; | 427 idx += count; |
422 out_len += count; | 428 out_len += count; |
423 } | 429 } |
424 else if (out_len > i) | 430 else if (out_len > i) |
425 { | 431 { |
426 /* Tricky part: rewinding... */ | 432 /* Tricky part: rewinding... */ |
427 unsigned int count = out_len - i; | 433 unsigned int count = out_len - i; |
428 | 434 |
| 435 /* This will blow in our face if memory allocation fails later |
| 436 * in this same lookup... */ |
429 if (unlikely (idx < count && !shift_forward (count + 32))) return false; | 437 if (unlikely (idx < count && !shift_forward (count + 32))) return false; |
430 | 438 |
431 assert (idx >= count); | 439 assert (idx >= count); |
432 | 440 |
433 idx -= count; | 441 idx -= count; |
434 out_len -= count; | 442 out_len -= count; |
435 memmove (info + idx, out_info + out_len, count * sizeof (out_info[0])); | 443 memmove (info + idx, out_info + out_len, count * sizeof (out_info[0])); |
436 } | 444 } |
437 | 445 |
438 return true; | 446 return true; |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 } | 1809 } |
1802 } | 1810 } |
1803 | 1811 |
1804 bool | 1812 bool |
1805 hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap) | 1813 hb_buffer_t::message_impl (hb_font_t *font, const char *fmt, va_list ap) |
1806 { | 1814 { |
1807 char buf[100]; | 1815 char buf[100]; |
1808 vsnprintf (buf, sizeof (buf), fmt, ap); | 1816 vsnprintf (buf, sizeof (buf), fmt, ap); |
1809 return (bool) this->message_func (this, font, buf, this->message_data); | 1817 return (bool) this->message_func (this, font, buf, this->message_data); |
1810 } | 1818 } |
OLD | NEW |