diff options
Diffstat (limited to 'xorg-server/glx/indirect_util.c')
-rw-r--r-- | xorg-server/glx/indirect_util.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/xorg-server/glx/indirect_util.c b/xorg-server/glx/indirect_util.c index f301c299d..36daf4f50 100644 --- a/xorg-server/glx/indirect_util.c +++ b/xorg-server/glx/indirect_util.c @@ -76,12 +76,17 @@ __glXGetAnswerBuffer(__GLXclientState * cl, size_t required_size, void *local_buffer, size_t local_size, unsigned alignment) { void *buffer = local_buffer; - const unsigned mask = alignment - 1; + const intptr_t mask = alignment - 1; if (local_size < required_size) { - const size_t worst_case_size = required_size + alignment; + size_t worst_case_size; intptr_t temp_buf; + if (required_size < SIZE_MAX - alignment) + worst_case_size = required_size + alignment; + else + return NULL; + if (cl->returnBufSize < worst_case_size) { void *temp = realloc(cl->returnBuf, worst_case_size); |