summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-10-09 15:17:17 +0200
committerJulien Cristau <jcristau@debian.org>2014-12-09 17:47:24 +0100
commit07b01bb5bd3587cd14d9dd2c8f4b145cf1757fe5 (patch)
tree38d12654f80b0c95d02a5d00f15ff5a997c0a498
parentd1bd02fb6746a4393e2538bf605b610e1764a413 (diff)
glx: check return from __glXGetAnswerBuffer
This function can return NULL; make sure every caller tests for that. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit 61a292adf45405641de1c522a04c148e0a152acd) Signed-off-by: Julien Cristau <jcristau@debian.org>
-rw-r--r--glx/indirect_dispatch.c25
-rw-r--r--glx/indirect_dispatch_swap.c26
2 files changed, 51 insertions, 0 deletions
diff --git a/glx/indirect_dispatch.c b/glx/indirect_dispatch.c
index 329b2e61e..f6cabefc8 100644
--- a/glx/indirect_dispatch.c
+++ b/glx/indirect_dispatch.c
@@ -2464,6 +2464,9 @@ __glXDisp_AreTexturesResident(__GLXclientState * cl, GLbyte * pc)
GLboolean answerBuffer[200];
GLboolean *residences =
__glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+ if (residences == NULL)
+ return BadAlloc;
retval =
glAreTexturesResident(n, (const GLuint *) (pc + 4), residences);
__glXSendReply(cl->client, residences, n, 1, GL_TRUE, retval);
@@ -2488,6 +2491,9 @@ __glXDisp_AreTexturesResidentEXT(__GLXclientState * cl, GLbyte * pc)
GLboolean answerBuffer[200];
GLboolean *residences =
__glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+ if (residences == NULL)
+ return BadAlloc;
retval =
glAreTexturesResident(n, (const GLuint *) (pc + 4), residences);
__glXSendReply(cl->client, residences, n, 1, GL_TRUE, retval);
@@ -2593,6 +2599,9 @@ __glXDisp_GenTextures(__GLXclientState * cl, GLbyte * pc)
GLuint *textures =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (textures == NULL)
+ return BadAlloc;
glGenTextures(n, textures);
__glXSendReply(cl->client, textures, n, 4, GL_TRUE, 0);
error = Success;
@@ -2616,6 +2625,9 @@ __glXDisp_GenTexturesEXT(__GLXclientState * cl, GLbyte * pc)
GLuint *textures =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (textures == NULL)
+ return BadAlloc;
glGenTextures(n, textures);
__glXSendReply(cl->client, textures, n, 4, GL_TRUE, 0);
error = Success;
@@ -3883,6 +3895,9 @@ __glXDisp_GenQueries(__GLXclientState * cl, GLbyte * pc)
GLuint *ids =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (ids == NULL)
+ return BadAlloc;
GenQueries(n, ids);
__glXSendReply(cl->client, ids, n, 4, GL_TRUE, 0);
error = Success;
@@ -4253,6 +4268,9 @@ __glXDisp_GenProgramsARB(__GLXclientState * cl, GLbyte * pc)
GLuint *programs =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (programs == NULL)
+ return BadAlloc;
GenProgramsARB(n, programs);
__glXSendReply(cl->client, programs, n, 4, GL_TRUE, 0);
error = Success;
@@ -4630,6 +4648,10 @@ __glXDisp_GenFramebuffers(__GLXclientState * cl, GLbyte * pc)
GLuint *framebuffers =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (framebuffers == NULL)
+ return BadAlloc;
+
GenFramebuffers(n, framebuffers);
__glXSendReply(cl->client, framebuffers, n, 4, GL_TRUE, 0);
error = Success;
@@ -4655,6 +4677,9 @@ __glXDisp_GenRenderbuffers(__GLXclientState * cl, GLbyte * pc)
GLuint *renderbuffers =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (renderbuffers == NULL)
+ return BadAlloc;
GenRenderbuffers(n, renderbuffers);
__glXSendReply(cl->client, renderbuffers, n, 4, GL_TRUE, 0);
error = Success;
diff --git a/glx/indirect_dispatch_swap.c b/glx/indirect_dispatch_swap.c
index 647d0c985..c0bb64d5d 100644
--- a/glx/indirect_dispatch_swap.c
+++ b/glx/indirect_dispatch_swap.c
@@ -2731,6 +2731,9 @@ __glXDispSwap_AreTexturesResident(__GLXclientState * cl, GLbyte * pc)
GLboolean answerBuffer[200];
GLboolean *residences =
__glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+ if (residences == NULL)
+ return BadAlloc;
retval =
glAreTexturesResident(n,
(const GLuint *)
@@ -2759,6 +2762,9 @@ __glXDispSwap_AreTexturesResidentEXT(__GLXclientState * cl, GLbyte * pc)
GLboolean answerBuffer[200];
GLboolean *residences =
__glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+ if (residences == NULL)
+ return BadAlloc;
retval =
glAreTexturesResident(n,
(const GLuint *)
@@ -2878,6 +2884,9 @@ __glXDispSwap_GenTextures(__GLXclientState * cl, GLbyte * pc)
GLuint *textures =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (textures == NULL)
+ return BadAlloc;
glGenTextures(n, textures);
(void) bswap_32_array((uint32_t *) textures, n);
__glXSendReplySwap(cl->client, textures, n, 4, GL_TRUE, 0);
@@ -2903,6 +2912,9 @@ __glXDispSwap_GenTexturesEXT(__GLXclientState * cl, GLbyte * pc)
GLuint *textures =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (textures == NULL)
+ return BadAlloc;
glGenTextures(n, textures);
(void) bswap_32_array((uint32_t *) textures, n);
__glXSendReplySwap(cl->client, textures, n, 4, GL_TRUE, 0);
@@ -4290,6 +4302,9 @@ __glXDispSwap_GenQueries(__GLXclientState * cl, GLbyte * pc)
GLuint *ids =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+ if (ids == NULL)
+ return BadAlloc;
+
GenQueries(n, ids);
(void) bswap_32_array((uint32_t *) ids, n);
__glXSendReplySwap(cl->client, ids, n, 4, GL_TRUE, 0);
@@ -4697,6 +4712,9 @@ __glXDispSwap_GenProgramsARB(__GLXclientState * cl, GLbyte * pc)
GLuint *programs =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+ if (programs == NULL)
+ return BadAlloc;
+
GenProgramsARB(n, programs);
(void) bswap_32_array((uint32_t *) programs, n);
__glXSendReplySwap(cl->client, programs, n, 4, GL_TRUE, 0);
@@ -5122,6 +5140,10 @@ __glXDispSwap_GenFramebuffers(__GLXclientState * cl, GLbyte * pc)
GLuint *framebuffers =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (framebuffers == NULL)
+ return BadAlloc;
+
GenFramebuffers(n, framebuffers);
(void) bswap_32_array((uint32_t *) framebuffers, n);
__glXSendReplySwap(cl->client, framebuffers, n, 4, GL_TRUE, 0);
@@ -5149,6 +5171,10 @@ __glXDispSwap_GenRenderbuffers(__GLXclientState * cl, GLbyte * pc)
GLuint *renderbuffers =
__glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
4);
+
+ if (renderbuffers == NULL)
+ return BadAlloc;
+
GenRenderbuffers(n, renderbuffers);
(void) bswap_32_array((uint32_t *) renderbuffers, n);
__glXSendReplySwap(cl->client, renderbuffers, n, 4, GL_TRUE, 0);