glz_dictionary_window_add_image: error out when failed to alloc an image

__glz_dictionary_window_alloc_image may return NULL.
Check that the image was created successfully and if not
then error out using dict->cur_usr->error like it's done
few lines below.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Uri Lublin 2020-05-17 18:08:44 +03:00 committed by Frediano Ziglio
parent 031ab732dd
commit 21323c8b6f

View File

@ -495,6 +495,9 @@ static WindowImage *glz_dictionary_window_add_image(SharedDictionary *dict, LzIm
uint8_t* lines = first_lines;
// alloc image info,update used head tail, if used_head null - update head
WindowImage *image = __glz_dictionary_window_alloc_image(dict);
if (!image) {
dict->cur_usr->error(dict->cur_usr, "glz-dictionary failed to allocate an image\n");
}
image->id = dict->last_image_id++;
image->size = image_size;
image->type = image_type;