do not use the picture after an allocation error
diff --git a/src/picture.c b/src/picture.c
index 74fe7c8..4ab5e0e 100644
--- a/src/picture.c
+++ b/src/picture.c
@@ -161,6 +161,7 @@
         picture_alloc_with_edges(&p->p, w, h, layout, bpc, p_allocator,
                                  t != NULL ? sizeof(atomic_int) * 2 : 0,
                                  (void **) &p->progress);
+    if (res) return res;
 
     p->visible = visible;
     p->flushed = 0;