From 3c31aa0987c63605bc5f3a30a7404415194762d8 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Thu, 18 May 2017 19:29:02 +1200 Subject: [PATCH] Fix potential leak on allocation failure in quirc_resize(). --- lib/quirc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/quirc.c b/lib/quirc.c index 62bc285..4eabe81 100644 --- a/lib/quirc.c +++ b/lib/quirc.c @@ -54,8 +54,12 @@ int quirc_resize(struct quirc *q, int w, int h) if (sizeof(*q->image) != sizeof(*q->pixels)) { size_t new_size = w * h * sizeof(quirc_pixel_t); quirc_pixel_t *new_pixels = realloc(q->pixels, new_size); - if (!new_pixels) + + if (!new_pixels) { + free(new_image); return -1; + } + q->pixels = new_pixels; }