[cairo-commit] 2 commits - src/cairo-type1-subset.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Fri Nov 2 17:39:08 PDT 2012


 src/cairo-type1-subset.c |   56 +++++++++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 23 deletions(-)

New commits:
commit cf07bd866dc3fdbfaf3d7e7fdc83cc2a4ef5698c
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Nov 3 11:08:01 2012 +1030

    type1-subset: remove unused variable

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 9bf75a7..d177fa9 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -785,7 +785,6 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
     unsigned char *charstring;
     const unsigned char *end;
     const unsigned char *p;
-    cairo_bool_t last_op_was_integer;
     int command;
 
     charstring = malloc (encrypted_charstring_length);
@@ -797,10 +796,7 @@ cairo_type1_font_subset_parse_charstring (cairo_type1_font_subset_t *font,
 						encrypted_charstring_length,
 						charstring);
     end = charstring + encrypted_charstring_length;
-
     p = charstring + font->lenIV;
-
-    last_op_was_integer = FALSE;
     status = CAIRO_STATUS_SUCCESS;
     while (p < end) {
         if (*p < 32) {
commit 9f537156adcab5e7a9b21cd2bb5cc7676db52713
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Nov 3 11:07:02 2012 +1030

    type1-subset: fix memory leak

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 2ec56f1..9bf75a7 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


More information about the cairo-commit mailing list