mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
progs/util: Fix memory leak if malloc fails in RawImageOpen.
(cherry picked from commit d36cb2396c)
This commit is contained in:
parent
305d4f147e
commit
0a6acecb35
1 changed files with 14 additions and 0 deletions
|
|
@ -130,6 +130,12 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||
if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL ||
|
||||
raw->tmpB == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
free(raw->tmp);
|
||||
free(raw->tmpR);
|
||||
free(raw->tmpG);
|
||||
free(raw->tmpB);
|
||||
free(raw->tmpA);
|
||||
free(raw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -139,6 +145,14 @@ static rawImageRec *RawImageOpen(const char *fileName)
|
|||
raw->rowSize = (GLint *)malloc(x);
|
||||
if (raw->rowStart == NULL || raw->rowSize == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
free(raw->tmp);
|
||||
free(raw->tmpR);
|
||||
free(raw->tmpG);
|
||||
free(raw->tmpB);
|
||||
free(raw->tmpA);
|
||||
free(raw->rowStart);
|
||||
free(raw->rowSize);
|
||||
free(raw);
|
||||
return NULL;
|
||||
}
|
||||
raw->rleEnd = 512 + (2 * x);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue