diff --git a/solution/src/transform.c b/solution/src/transform.c
index 4aebc2f12dc5e35a2ffb81e3ab59f467d89c7554..f65add23e912f3c8571025abe6e95aa2c1ca880e 100644
--- a/solution/src/transform.c
+++ b/solution/src/transform.c
@@ -4,6 +4,9 @@
 
 struct image rotate_cw90(const struct image* img) {
     struct image rotated = image_create(img->height, img->width);
+    if (!rotated.data) {
+        return rotated;
+    }
     for (uint64_t y = 0; y < img->height; y++) {
         for (uint64_t x = 0; x < img->width; x++) {
             rotated.data[x * rotated.width + (rotated.width - 1 - y)] = img->data[y * img->width + x];
@@ -14,6 +17,9 @@ struct image rotate_cw90(const struct image* img) {
 
 struct image rotate_ccw90(const struct image* img) {
     struct image rotated = image_create(img->height, img->width);
+     if (!rotated.data) {
+        return rotated;
+    }
     for (uint64_t y = 0; y < img->height; y++) {
         for (uint64_t x = 0; x < img->width; x++) {
             rotated.data[(rotated.height - 1 - x) * rotated.width + y] = img->data[y * img->width + x];
@@ -24,6 +30,9 @@ struct image rotate_ccw90(const struct image* img) {
 
 struct image flip_horizontal(const struct image* img) {
     struct image flipped = image_create(img->width, img->height);
+     if (!flipped.data) {
+        return flipped;
+    }
     for (uint64_t y = 0; y < img->height; y++) {
         for (uint64_t x = 0; x < img->width; x++) {
             flipped.data[y * flipped.width + (flipped.width - 1 - x)] = img->data[y * img->width + x];
@@ -34,6 +43,9 @@ struct image flip_horizontal(const struct image* img) {
 
 struct image flip_vertical(const struct image* img) {
     struct image flipped = image_create(img->width, img->height);
+    if (!flipped.data) {
+        return flipped;
+    }
     for (uint64_t y = 0; y < img->height; y++) {
         for (uint64_t x = 0; x < img->width; x++) {
             flipped.data[(flipped.height - 1 - y) * flipped.width + x] = img->data[y * img->width + x];
@@ -43,6 +55,9 @@ struct image flip_vertical(const struct image* img) {
 }
 struct image image_copy(const struct image* img) {
    struct image copy = image_create(img->width, img->height);
+   if (!copy.data) {
+        return copy;
+    }
     if (copy.data) {
         memcpy(
             copy.data,