diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-01-02 10:37:58 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-01-03 11:03:17 +0000 |
commit | fd8bf678536877d9b016264d40a101a1fd2d9e25 (patch) | |
tree | ce647c668d8d5e518372a0279ed530ca30b9f06b /src | |
parent | ad0a2524ffdc9cc949d11de3aa51c429f13e12b7 (diff) |
[cairo-truetype-subset] Propagate error from failing to allocate padding.
Before filling the padding, check that we have successfully allocated
the buffer - otherwise propagate the failure.
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-truetype-subset.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index 5e392d42..557ab1d6 100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -323,7 +323,7 @@ cairo_truetype_font_allocate_write_buffer (cairo_truetype_font_t *font, return CAIRO_STATUS_SUCCESS; } -static cairo_status_t +static void cairo_truetype_font_write (cairo_truetype_font_t *font, const void *data, size_t length) @@ -331,13 +331,11 @@ cairo_truetype_font_write (cairo_truetype_font_t *font, cairo_status_t status; if (font->status) - return font->status; + return; status = _cairo_array_append_multiple (&font->output, data, length); if (status) - return _cairo_truetype_font_set_error (font, status); - - return CAIRO_STATUS_SUCCESS; + status = _cairo_truetype_font_set_error (font, status); } static void @@ -366,22 +364,29 @@ cairo_truetype_font_write_be32 (cairo_truetype_font_t *font, cairo_truetype_font_write (font, &be32_value, sizeof be32_value); } -static unsigned long -cairo_truetype_font_align_output (cairo_truetype_font_t *font) +static cairo_status_t +cairo_truetype_font_align_output (cairo_truetype_font_t *font, + unsigned long *aligned) { - int length, aligned, pad; + int length, pad; unsigned char *padding; length = _cairo_array_num_elements (&font->output); - aligned = (length + 3) & ~3; - pad = aligned - length; + *aligned = (length + 3) & ~3; + pad = *aligned - length; if (pad) { - cairo_truetype_font_allocate_write_buffer (font, pad, &padding); + cairo_status_t status; + + status = cairo_truetype_font_allocate_write_buffer (font, pad, + &padding); + if (status) + return status; + memset (padding, 0, pad); } - return aligned; + return CAIRO_STATUS_SUCCESS; } static cairo_status_t @@ -575,8 +580,9 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font, } size = end - begin; - - next = cairo_truetype_font_align_output (font); + status = cairo_truetype_font_align_output (font, &next); + if (status) + goto FAIL; status = cairo_truetype_font_check_boundary (font, next); if (status) @@ -598,8 +604,11 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font, } } - font->glyphs[i].location = - cairo_truetype_font_align_output (font) - start_offset; + status = cairo_truetype_font_align_output (font, &next); + if (status) + goto FAIL; + + font->glyphs[i].location = next - start_offset; status = font->status; FAIL: @@ -881,8 +890,9 @@ cairo_truetype_font_generate (cairo_truetype_font_t *font, if (status) goto FAIL; - start = cairo_truetype_font_align_output (font); - end = start; + status = cairo_truetype_font_align_output (font, &start); + if (status) + goto FAIL; end = 0; for (i = 0; i < font->num_tables; i++) { @@ -891,7 +901,10 @@ cairo_truetype_font_generate (cairo_truetype_font_t *font, goto FAIL; end = _cairo_array_num_elements (&font->output); - next = cairo_truetype_font_align_output (font); + status = cairo_truetype_font_align_output (font, &next); + if (status) + goto FAIL; + cairo_truetype_font_update_entry (font, font->truetype_tables[i].pos, font->truetype_tables[i].tag, start, end); status = cairo_truetype_font_check_boundary (font, next); |