Fix potential leak on allocation failure in quirc_resize().
This commit is contained in:
parent
c4abca0eec
commit
3c31aa0987
1 changed files with 5 additions and 1 deletions
|
@ -54,8 +54,12 @@ int quirc_resize(struct quirc *q, int w, int h)
|
||||||
if (sizeof(*q->image) != sizeof(*q->pixels)) {
|
if (sizeof(*q->image) != sizeof(*q->pixels)) {
|
||||||
size_t new_size = w * h * sizeof(quirc_pixel_t);
|
size_t new_size = w * h * sizeof(quirc_pixel_t);
|
||||||
quirc_pixel_t *new_pixels = realloc(q->pixels, new_size);
|
quirc_pixel_t *new_pixels = realloc(q->pixels, new_size);
|
||||||
if (!new_pixels)
|
|
||||||
|
if (!new_pixels) {
|
||||||
|
free(new_image);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
q->pixels = new_pixels;
|
q->pixels = new_pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue