OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 hb_blob_create (const char *data, | 97 hb_blob_create (const char *data, |
98 unsigned int length, | 98 unsigned int length, |
99 hb_memory_mode_t mode, | 99 hb_memory_mode_t mode, |
100 void *user_data, | 100 void *user_data, |
101 hb_destroy_func_t destroy) | 101 hb_destroy_func_t destroy) |
102 { | 102 { |
103 hb_blob_t *blob; | 103 hb_blob_t *blob; |
104 | 104 |
105 if (!length || | 105 if (!length || |
106 length >= 1u << 31 || | 106 length >= 1u << 31 || |
107 data + length < data /* overflows */ || | |
108 !(blob = hb_object_create<hb_blob_t> ())) { | 107 !(blob = hb_object_create<hb_blob_t> ())) { |
109 if (destroy) | 108 if (destroy) |
110 destroy (user_data); | 109 destroy (user_data); |
111 return hb_blob_get_empty (); | 110 return hb_blob_get_empty (); |
112 } | 111 } |
113 | 112 |
114 blob->data = data; | 113 blob->data = data; |
115 blob->length = length; | 114 blob->length = length; |
116 blob->mode = mode; | 115 blob->mode = mode; |
117 | 116 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 469 |
471 memcpy (new_data, blob->data, blob->length); | 470 memcpy (new_data, blob->data, blob->length); |
472 _hb_blob_destroy_user_data (blob); | 471 _hb_blob_destroy_user_data (blob); |
473 blob->mode = HB_MEMORY_MODE_WRITABLE; | 472 blob->mode = HB_MEMORY_MODE_WRITABLE; |
474 blob->data = new_data; | 473 blob->data = new_data; |
475 blob->user_data = new_data; | 474 blob->user_data = new_data; |
476 blob->destroy = free; | 475 blob->destroy = free; |
477 | 476 |
478 return true; | 477 return true; |
479 } | 478 } |
OLD | NEW |