*> Looks good!  Please submit a Pull Request that Armin (and others) can >
review. *

Done!

The fuzzer already found a bug in the renderer, I have attached a patch
(diff.txt) to
fix this (https://github.com/freetype/freetype2-testing/runs/3213214141).
If you require a merge request instead, then I'll make it tomorrow.

Also, there is a timeout in one of the tests:
240 - truetype-render-i38:oss-fuzz/10398-5653547685773312-timeout (Timeout)
Is there a way to increase the timeout ? As I would like to test this
locally
and confirm that it's just a timeout and not a bug.

*> I think generally there are two options:*









* > > - We do have a few screws at this point to steer how many glyphs
we're > looking at in a single fuzzer run.  We could either use one of the
existing > ones or, if they are to coarse, we could introduce new screws
that > specifically target the SDF mode. > > - Alternatively SDF could get
it's very own fuzzer.  We've already done this > to separate rendering from
utility access;  we _could_ look into further > separating fuzzing
rendering from fuzzing SDF rendering.  Although, that*
*> would be quite a lot of work. *

Seeing how slow the `sdf` renderer is I think the second option would
be better. Dominik recently added the COLRv1 fuzzer, if the process is
similar, then I can work on adding a new fuzzer for SDF.

Thanks,
Anuj
diff --git a/src/sdf/ftsdfrend.c b/src/sdf/ftsdfrend.c
index 420ad496c..6fd104dbf 100644
--- a/src/sdf/ftsdfrend.c
+++ b/src/sdf/ftsdfrend.c
@@ -350,6 +350,8 @@
     error = render->raster_render( render->raster,
                                    (const FT_Raster_Params*)&params );
 
+    if ( x_shift || y_shift )
+      FT_Outline_Translate( outline, -x_shift, -y_shift );
   Exit:
     if ( !error )
     {
@@ -362,9 +364,6 @@
       slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
     }
 
-    if ( x_shift || y_shift )
-      FT_Outline_Translate( outline, -x_shift, -y_shift );
-
     return error;
   }
 
@@ -506,6 +505,16 @@
       goto Exit;
     }
 
+    /* do not convert to SDF if the bitmap is not owned by glyph */
+    if ( !(slot->internal->flags & FT_GLYPH_OWN_BITMAP) )
+    {
+      FT_ERROR(( "ft_bsdf_render: can't convert bitmap to sdf;\n" ));
+      FT_ERROR(( "                bitmap not owned by glyph.\n"   ));
+
+      error = FT_THROW( Invalid_Argument );
+      goto Exit;
+    }
+
     if ( !bitmap->rows || !bitmap->pitch )
       goto Exit;
 

Reply via email to