]> granicus.if.org Git - libass/commitdiff
Handle clip vector rasterizer errors
authorGrigori Goronzy <greg@blackbox>
Fri, 24 Jul 2009 08:35:17 +0000 (10:35 +0200)
committerGrigori Goronzy <greg@blackbox>
Fri, 24 Jul 2009 13:39:20 +0000 (15:39 +0200)
If rasterizing the clip vector fails, actually handle the situation
instead of crashing.

libass/ass_render.c

index 7b85706935da1e830fcd37e4d7a5c1ab6c9e53d8..d2f3c1bca5138e160f8cc088420afbbc34acf68e 100644 (file)
@@ -743,13 +743,19 @@ static void blend_vector_clip(ass_renderer_t *render_priv,
     FT_BitmapGlyph clip_bm;
     ass_image_t *cur;
     ass_drawing_t *drawing = render_priv->state.clip_drawing;
+    int error;
 
     if (!drawing)
         return;
 
     // Rasterize it
     FT_Glyph_Copy((FT_Glyph) drawing->glyph, &glyph);
-    FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
+    error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
+    if (error) {
+        ass_msg(render_priv->library, MSGL_V,
+            "Clip vector rasterization failed: %d. Skipping.", error);
+        goto blend_vector_exit;
+    }
     clip_bm = (FT_BitmapGlyph) glyph;
     clip_bm->top = -clip_bm->top;
 
@@ -832,6 +838,7 @@ static void blend_vector_clip(ass_renderer_t *render_priv,
 
     // Free clip vector and its bitmap, we don't need it anymore
     FT_Done_Glyph(glyph);
+blend_vector_exit:
     ass_drawing_free(render_priv->state.clip_drawing);
     render_priv->state.clip_drawing = 0;
 }