scale: fix a potential memory leak (#2915)

diff --git a/src/scale.c b/src/scale.c
index 3d64774..777eca4 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -141,7 +141,8 @@
         const avifResult allocationResult = avifImageAllocatePlanes(image, AVIF_PLANES_A);
         if (allocationResult != AVIF_RESULT_OK) {
             avifDiagnosticsPrintf(diag, "Allocation of alpha plane failed: %s", avifResultToString(allocationResult));
-            return AVIF_RESULT_OUT_OF_MEMORY;
+            result = AVIF_RESULT_OUT_OF_MEMORY;
+            goto cleanup;
         }
 
         if (image->depth > 8) {