### ImageMagick version

7.1.1-15

### Operating system

Linux

### Operating system, version and so on

CentOS Stream release 8

### Description

```c
#include <MagickWand/MagickWand.h>
#include <stdio.h>

int main() {
        unsigned char *image_contents;
        size_t image_size;

        MagickWand *magick_wand = NewMagickWand();

        MagickBooleanType status = MagickSetSize(magick_wand, 640, 480);
        printf("status = %d\n", status);

        int res = MagickReadImage(magick_wand, "gradient:red-blue");
        printf("res = %d\n", res);

        image_contents = MagickGetImageBlob(magick_wand, &image_size);
        printf("image_contents = %p\n", image_contents);

        DestroyMagickWand(magick_wand);

        return 0;
}

```

In this code, MagickGetImageBlob() returns NULL, which makes it impossible to release acquired memory (and it looks correct).

But actually, allocation happens

```
$ cc -lMagickCore-7.Q16HDRI -lMagickWand-7.Q16HDRI -fsanitize=address test.cc && ./a.out
status = 1
res = 1
image_contents = (nil)

=================================================================
==6217==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 65536 byte(s) in 1 object(s) allocated from:
    #0 0x7fac42981bb8 in __interceptor_malloc (/lib64/libasan.so.5+0xefbb8)
    #1 0x7fac41c7959d in ImageToBlob MagickCore/blob.c:2072
    #2 0x400b58 in main /build/test.cc:16
    #3 0x7fac4125cd84 in __libc_start_main (/lib64/libc.so.6+0x3ad84)

SUMMARY: AddressSanitizer: 65536 byte(s) leaked in 1 allocation(s).
```

It looks like ([code link](https://github.com/ImageMagick/ImageMagick/blob/cf690f5f2a6772609817aa4b976489dcf1a41afe/MagickCore/blob.c#L2072))
```
blob_info->blob=AcquireQuantumMemory(MagickMaxBlobExtent,
        sizeof(unsigned char));
```

is not released if `blob=DetachBlob(image->blob);` returns NULL

### Steps to Reproduce

see above

### Images

_No response_
Memleak in MagickGetImageBlob()
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Memleak in MagickGetImageBlob()
Issue date:

--- start body ---
### ImageMagick version

7.1.1-15

### Operating system

Linux

### Operating system, version and so on

CentOS Stream release 8

### Description

```c
#include <MagickWand/MagickWand.h>
#include <stdio.h>

int main() {
        unsigned char *image_contents;
        size_t image_size;

        MagickWand *magick_wand = NewMagickWand();

        MagickBooleanType status = MagickSetSize(magick_wand, 640, 480);
        printf("status = %d\n", status);

        int res = MagickReadImage(magick_wand, "gradient:red-blue");
        printf("res = %d\n", res);

        image_contents = MagickGetImageBlob(magick_wand, &image_size);
        printf("image_contents = %p\n", image_contents);

        DestroyMagickWand(magick_wand);

        return 0;
}

```

In this code, MagickGetImageBlob() returns NULL, which makes it impossible to release acquired memory (and it looks correct).

But actually, allocation happens

```
$ cc -lMagickCore-7.Q16HDRI -lMagickWand-7.Q16HDRI -fsanitize=address test.cc && ./a.out
status = 1
res = 1
image_contents = (nil)

=================================================================
==6217==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 65536 byte(s) in 1 object(s) allocated from:
    #0 0x7fac42981bb8 in __interceptor_malloc (/lib64/libasan.so.5+0xefbb8)
    #1 0x7fac41c7959d in ImageToBlob MagickCore/blob.c:2072
    #2 0x400b58 in main /build/test.cc:16
    #3 0x7fac4125cd84 in __libc_start_main (/lib64/libc.so.6+0x3ad84)

SUMMARY: AddressSanitizer: 65536 byte(s) leaked in 1 allocation(s).
```

It looks like ([code link](https://github.com/ImageMagick/ImageMagick/blob/cf690f5f2a6772609817aa4b976489dcf1a41afe/MagickCore/blob.c#L2072))
```
blob_info->blob=AcquireQuantumMemory(MagickMaxBlobExtent,
        sizeof(unsigned char));
```

is not released if `blob=DetachBlob(image->blob);` returns NULL

### Steps to Reproduce

see above

### Images

_No response_
--- end body ---
