Mesa (mesa_7_6_branch): progs/util: Exit RawImageGetData early if malloc fails.

Vinson Lee vlee at kemper.freedesktop.org
Fri Dec 4 01:14:55 UTC 2009


Module: Mesa
Branch: mesa_7_6_branch
Commit: a0ac8fc7d8d946183ba0506a8134a6e55819e151
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0ac8fc7d8d946183ba0506a8134a6e55819e151

Author: Vinson Lee <vlee at vmware.com>
Date:   Fri Nov 20 12:11:55 2009 -0800

progs/util: Exit RawImageGetData early if malloc fails.

Prevents a null pointer deference later on.
(cherry picked from commit e26135a744f740430e3dc341fa692544ba99c11e)

---

 progs/util/readtex.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/progs/util/readtex.c b/progs/util/readtex.c
index 1e1183c..81cb626 100644
--- a/progs/util/readtex.c
+++ b/progs/util/readtex.c
@@ -230,6 +230,7 @@ static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final)
    final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4);
    if (final->data == NULL) {
       fprintf(stderr, "Out of memory!\n");
+      return;
    }
 
    ptr = final->data;




More information about the mesa-commit mailing list