summaryrefslogtreecommitdiff
path: root/progs/util
diff options
context:
space:
mode:
authorVinson Lee <vlee@vmware.com>2009-11-20 11:22:13 -0800
committerVinson Lee <vlee@vmware.com>2009-11-20 11:22:13 -0800
commitd36cb2396c942f05ba56c5b899792a507bb0f0fd (patch)
tree558e2f3048a3dfa9567d4c1bbc4a43603c1aa40e /progs/util
parent08cb1d0ce4765536f1cb6a9253a2245c31fb8ea9 (diff)
progs/util: Fix memory leak if malloc fails in RawImageOpen.
Diffstat (limited to 'progs/util')
-rw-r--r--progs/util/readtex.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/progs/util/readtex.c b/progs/util/readtex.c
index 3922998fd5..1e1183cf9a 100644
--- a/progs/util/readtex.c
+++ b/progs/util/readtex.c
@@ -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);