cairo, svg: ignore empty blocks
Fixes crash bug found with the afl fuzzer.
Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
diff --git a/cairo.c b/cairo.c
index 23dd628..0683848 100644
--- a/cairo.c
+++ b/cairo.c
@@ -28,6 +28,9 @@
struct stitch *stitch = block->stitch;
int i;
+ if (!block->nr_stitches)
+ continue;
+
cairo_set_source_rgb(cr, c->r / 255.0, c->g / 255.0, c->b / 255.0);
cairo_move_to(cr, X(stitch), Y(stitch));
diff --git a/svg.c b/svg.c
index 1237a64..d1c81f0 100644
--- a/svg.c
+++ b/svg.c
@@ -14,6 +14,9 @@
pes->max_y - pes->min_y);
for (struct pes_block *block = pes->blocks; block; block = block->next) {
+ if (!block->nr_stitches)
+ continue;
+
int i;
printf("<path stroke=\"#%02x%02x%02x\" fill=\"none\" d=\"M %d %d",
block->color->r,