Check we really got memory we were asking for.
Signed-off-by: Juha-Pekka Heikkila <[email protected]>
---
src/mesa/main/pack.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index d1f368c..da2128d 100644
--- a/src/mesa/main/pack.c
+++ b/src/mesa/main/pack.c
@@ -1611,9 +1611,17 @@ _mesa_unpack_color_index_to_rgba_ubyte(struct gl_context
*ctx, GLuint dims,
src, srcFormat, srcType,
srcWidth, srcHeight, srcDepth,
srcPacking, transferOps);
+ if (!rgba)
+ return NULL;
count = srcWidth * srcHeight * srcDepth;
dst = malloc(count * 4 * sizeof(GLubyte));
+ if (!dst) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "pixel unpacking");
+ free(rgba);
+ return NULL;
+ }
+
for (i = 0; i < count; i++) {
CLAMPED_FLOAT_TO_UBYTE(dst[i * 4 + 0], rgba[i * 4 + 0]);
CLAMPED_FLOAT_TO_UBYTE(dst[i * 4 + 1], rgba[i * 4 + 1]);
--
1.8.5.1
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev