is there memory leak
#include <stdio.h>
#include <stdlib.h>

struct pixel {
    unsigned char blue;
    unsigned char green;
    unsigned char red;
};

void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height);
struct pixel **read_pixel_array(FILE *image, int pixel_array_offset, int width, int height);
void print_pixel(struct pixel p);

struct pixel **read_pixel_array(FILE *image, int pixel_array_offset, int width, int height) {
    struct pixel **pixel_array = malloc(height*sizeof(struct pixel *));
    if (pixel_array == NULL){
        perror("Unable to malloc space");
        exit(1);
    }
    for(int i = 0; i < height; i++){
        pixel_array[i] = malloc(width*3);
        if (pixel_array[i] == NULL){
            perror("Unable to malloc space");
            exit(1);
        }
        for(int j = 0; j < width; j++){
            if (fseek(image, (pixel_array_offset + 8 * (height * i + j)), SEEK_SET) != 0){
                perror("Unable to navigate in image file");
                exit(1);
            }
            if (fread(&(pixel_array[i][j].blue), sizeof(int), 1, image) != 1){
                perror("Error when reading pixel data");
                exit(1);
            }
            if (fread(&(pixel_array[i][j].green), sizeof(int), 1, image) != 1){
                perror("Error when reading pixel data");
                exit(1);
            }
            if (fread(&(pixel_array[i][j].red), sizeof(int), 1, image) != 1){
                perror("Error when reading pixel data");
                exit(1);
            }
        }
    }
    return pixel_array;
}

void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) {
    if (sizeof(int) != 4){
        perror("Size of integer in this machine does not match file detail requirement");
        exit(1);
    }
    if (fseek(image, 10, SEEK_SET) != 0){
        perror("Unable to navigate in image file");
        exit(1);
    }
    if (fread(pixel_array_offset, sizeof(int), 1, image) != 1){
        perror("Error when reading array starting point data");
        exit(1);
    }
    if (fseek(image, 18, SEEK_SET) != 0){
        perror("Unable to navigate in image file");
        exit(1);
    }
    if (fread(width, sizeof(int), 1, image) != 1){
        perror("Error when reading width data");
        exit(1);
    }
    if (fseek(image, 22, SEEK_SET) != 0){
        perror("Unable to navigate in image file");
        exit(1);
    }
    if (fread(height, sizeof(int), 1, image) != 1){
        perror("Error when reading height data");
        exit(1);
    }
}

void print_pixel(struct pixel p) {
    printf("(%u, %u, %u)\n", p.blue, p.green, p.red);
}

int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr, "Usage: bitmap_printer input_bmp\n");
        exit(1);
    }

    FILE *image = fopen(argv[1], "rb");
    if (image == NULL) {
        fprintf(stderr, "Cannot open file\n");
        exit(1);
    }

    // Read in bitmap file metadata
    int pixel_array_offset, width, height;
    read_bitmap_metadata(image, &pixel_array_offset, &width, &height);

    // Print out metadata.
    printf("Pixel array offset: %d\n", pixel_array_offset);
    printf("Width: %d\n", width);
    printf("Height: %d\n", height);

    // Read in the pixel data
    struct pixel **pixels = read_pixel_array(image, pixel_array_offset, width, height);

    // Print out some pixels from each of the image's corners.
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            print_pixel(pixels[i][j]);
            print_pixel(pixels[i][width - 1 - j]);
            print_pixel(pixels[height - 1 - i][j]);
            print_pixel(pixels[height - 1 - i][width - 1 - j]);
        }
    }

    // Clean up: you need to do this!
    if (fclose(image) != 0){
        perror("Unable to close image");
        return 1;
    }
    for (int i = 0; i < width; i++){
        free(pixels[i]);
    }
    free(pixels);
    return 0;
}
