Check OOM in avifImageCreate, avifEncoderCreate
The goal is to remove the abort() call from avifAlloc() once all
libavif functions check potential out-of-memory errors.
Add avifimagetest.
diff --git a/examples/avif_example_encode.c b/examples/avif_example_encode.c
index 0480ba4..31b00d1 100644
--- a/examples/avif_example_encode.c
+++ b/examples/avif_example_encode.c
@@ -26,6 +26,10 @@
memset(&rgb, 0, sizeof(rgb));
avifImage * image = avifImageCreate(128, 128, 8, AVIF_PIXEL_FORMAT_YUV444); // these values dictate what goes into the final AVIF
+ if (!image) {
+ fprintf(stderr, "Out of memory\n");
+ goto cleanup;
+ }
// Configure image here: (see avif/avif.h)
// * colorPrimaries
// * transferCharacteristics
@@ -75,6 +79,10 @@
}
encoder = avifEncoderCreate();
+ if (!encoder) {
+ fprintf(stderr, "Out of memory\n");
+ goto cleanup;
+ }
// Configure your encoder here (see avif/avif.h):
// * maxThreads
// * quality