summaryrefslogtreecommitdiff
path: root/src/cairo-type1-subset.c
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2012-11-03 11:07:02 +1030
committerAdrian Johnson <ajohnson@redneon.com>2012-11-03 11:07:02 +1030
commit9f537156adcab5e7a9b21cd2bb5cc7676db52713 (patch)
tree65bd177d2a7486e11ccd4f0162946ae32abf2c12 /src/cairo-type1-subset.c
parent724c6dfa9521e887682029add879c2fcdd518b14 (diff)
downloadcairo-9f537156adcab5e7a9b21cd2bb5cc7676db52713.tar.gz
type1-subset: fix memory leak
Diffstat (limited to 'src/cairo-type1-subset.c')
-rw-r--r--src/cairo-type1-subset.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 2ec56f157..9bf75a7ac 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -801,7 +801,7 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
p = charstring + font->lenIV;
last_op_was_integer = FALSE;
-
+ status = CAIRO_STATUS_SUCCESS;
while (p < end) {
if (*p < 32) {
command = *p++;
@@ -845,8 +845,10 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
break;
case TYPE1_CHARSTRING_COMMAND_HSBW:
- if (font->build_stack.sp < 2)
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ if (font->build_stack.sp < 2) {
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
+ }
font->glyphs[glyph].width = font->build_stack.stack[1]/font->base.units_per_em;
font->build_stack.sp = 0;
@@ -871,23 +873,27 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
* glyph is composed from. All we need to do is to
* make sure those glyphs are present in the subset
* under their standard names. */
- if (font->build_stack.sp < 5)
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ if (font->build_stack.sp < 5) {
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
+ }
status = use_standard_encoding_glyph (font, font->build_stack.stack[3]);
if (unlikely (status))
- return status;
+ goto cleanup;
status = use_standard_encoding_glyph (font, font->build_stack.stack[4]);
if (unlikely (status))
- return status;
+ goto cleanup;
font->build_stack.sp = 0;
break;
case TYPE1_CHARSTRING_COMMAND_SBW:
- if (font->build_stack.sp < 4)
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ if (font->build_stack.sp < 4) {
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
+ }
font->glyphs[glyph].width = font->build_stack.stack[2]/font->base.units_per_em;
font->build_stack.sp = 0;
@@ -895,21 +901,25 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
case TYPE1_CHARSTRING_COMMAND_DIV:
if (font->build_stack.sp < 2) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
} else {
double num1 = font->build_stack.stack[font->build_stack.sp - 2];
double num2 = font->build_stack.stack[font->build_stack.sp - 1];
font->build_stack.sp--;
- if (num2 == 0.0)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
+ if (num2 == 0.0) {
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
+ }
font->build_stack.stack[font->build_stack.sp - 1] = num1/num2;
}
break;
case TYPE1_CHARSTRING_COMMAND_CALLOTHERSUBR:
- if (font->build_stack.sp < 1)
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ if (font->build_stack.sp < 1) {
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
+ }
font->build_stack.sp--;
font->ps_stack.sp = 0;
@@ -919,8 +929,10 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
break;
case TYPE1_CHARSTRING_COMMAND_POP:
- if (font->ps_stack.sp < 1)
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ if (font->ps_stack.sp < 1) {
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
+ }
/* T1 spec states that if the interpreter does not
* support executing the callothersub, the results
@@ -937,14 +949,16 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
p = cairo_type1_font_subset_decode_integer (p, &val);
font->build_stack.stack[font->build_stack.sp++] = val;
} else {
- return CAIRO_INT_STATUS_UNSUPPORTED;
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ goto cleanup;
}
}
}
+cleanup:
free (charstring);
- return CAIRO_STATUS_SUCCESS;
+ return status;
}
static cairo_status_t