Bug Summary

File:glx/singlepix.c
Location:line 231, column 5
Description:Call to 'realloc' has an allocation size of 0 bytes

Annotated Source Code

1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30
31#ifdef HAVE_DIX_CONFIG_H1
32#include <dix-config.h>
33#endif
34
35#include "glxserver.h"
36#include "glxext.h"
37#include "singlesize.h"
38#include "unpack.h"
39#include "indirect_size_get.h"
40#include "indirect_dispatch.h"
41
42int
43__glXDisp_ReadPixels(__GLXclientState * cl, GLbyte * pc)
44{
45 GLsizei width, height;
46 GLenum format, type;
47 GLboolean swapBytes, lsbFirst;
48 GLint compsize;
49 __GLXcontext *cx;
50 ClientPtr client = cl->client;
51 int error;
52 char *answer, answerBuffer[200];
53
54 REQUEST_FIXED_SIZE(xGLXSingleReq, 28)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((28) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (28) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
55
56 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
57 if (!cx) {
58 return error;
59 }
60
61 pc += __GLX_SINGLE_HDR_SIZE8;
62 width = *(GLsizei *) (pc + 8);
63 height = *(GLsizei *) (pc + 12);
64 format = *(GLenum *) (pc + 16);
65 type = *(GLenum *) (pc + 20);
66 swapBytes = *(GLboolean *) (pc + 24);
67 lsbFirst = *(GLboolean *) (pc + 25);
68 compsize = __glReadPixels_size(format, type, width, height);
69 if (compsize < 0)
70 return BadLength16;
71
72 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
73 glPixelStorei(GL_PACK_LSB_FIRST0x0D01, lsbFirst);
74 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1)if (compsize < 0) return 16; else if ((compsize) > sizeof
(answerBuffer)) { int bump; if ((cl)->returnBufSize < (
compsize)+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->
returnBuf, (compsize)+(1)); if (!(cl)->returnBuf) { return
11; } (cl)->returnBufSize = (compsize)+(1); } answer = (char
*)cl->returnBuf; bump = (long)(answer) % (1); if (bump) answer
+= (1) - (bump); } else { answer = (char *)answerBuffer; }
;
75 __glXClearErrorOccured();
76 glReadPixels(*(GLint *) (pc + 0), *(GLint *) (pc + 4),
77 *(GLsizei *) (pc + 8), *(GLsizei *) (pc + 12),
78 *(GLenum *) (pc + 16), *(GLenum *) (pc + 20), answer);
79
80 if (__glXErrorOccured()) {
81 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
82 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
83 }
84 else {
85 __GLX_BEGIN_REPLY(compsize)__glXReply.length = (((compsize)+3) & (GLuint)~3) >>
2; __glXReply.type = 1; __glXReply.sequenceNumber = client->
sequence;
;
86 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
87 __GLX_SEND_VOID_ARRAY(compsize)WriteToClient(client, ((((compsize)*1)+3) & (GLuint)~3), answer
)
;
88 }
89 return Success0;
90}
91
92int
93__glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
94{
95 GLint level, compsize;
96 GLenum format, type, target;
97 GLboolean swapBytes;
98 __GLXcontext *cx;
99 ClientPtr client = cl->client;
100 int error;
101 char *answer, answerBuffer[200];
102 GLint width = 0, height = 0, depth = 1;
103
104 REQUEST_FIXED_SIZE(xGLXSingleReq, 20)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((20) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (20) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
105
106 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
107 if (!cx) {
108 return error;
109 }
110
111 pc += __GLX_SINGLE_HDR_SIZE8;
112 level = *(GLint *) (pc + 4);
113 format = *(GLenum *) (pc + 8);
114 type = *(GLenum *) (pc + 12);
115 target = *(GLenum *) (pc + 0);
116 swapBytes = *(GLboolean *) (pc + 16);
117
118 glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH0x1000, &width);
119 glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT0x1001, &height);
120 if (target == GL_TEXTURE_3D0x806F) {
121 glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH0x8071, &depth);
122 }
123 /*
124 * The three queries above might fail if we're in a state where queries
125 * are illegal, but then width, height, and depth would still be zero anyway.
126 */
127 compsize =
128 __glGetTexImage_size(target, level, format, type, width, height, depth);
129 if (compsize < 0)
130 return BadLength16;
131
132 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
133 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1)if (compsize < 0) return 16; else if ((compsize) > sizeof
(answerBuffer)) { int bump; if ((cl)->returnBufSize < (
compsize)+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->
returnBuf, (compsize)+(1)); if (!(cl)->returnBuf) { return
11; } (cl)->returnBufSize = (compsize)+(1); } answer = (char
*)cl->returnBuf; bump = (long)(answer) % (1); if (bump) answer
+= (1) - (bump); } else { answer = (char *)answerBuffer; }
;
134 __glXClearErrorOccured();
135 glGetTexImage(*(GLenum *) (pc + 0), *(GLint *) (pc + 4),
136 *(GLenum *) (pc + 8), *(GLenum *) (pc + 12), answer);
137
138 if (__glXErrorOccured()) {
139 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
140 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
141 }
142 else {
143 __GLX_BEGIN_REPLY(compsize)__glXReply.length = (((compsize)+3) & (GLuint)~3) >>
2; __glXReply.type = 1; __glXReply.sequenceNumber = client->
sequence;
;
144 ((xGLXGetTexImageReply *) &__glXReply)->width = width;
145 ((xGLXGetTexImageReply *) &__glXReply)->height = height;
146 ((xGLXGetTexImageReply *) &__glXReply)->depth = depth;
147 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
148 __GLX_SEND_VOID_ARRAY(compsize)WriteToClient(client, ((((compsize)*1)+3) & (GLuint)~3), answer
)
;
149 }
150 return Success0;
151}
152
153int
154__glXDisp_GetPolygonStipple(__GLXclientState * cl, GLbyte * pc)
155{
156 GLboolean lsbFirst;
157 __GLXcontext *cx;
158 ClientPtr client = cl->client;
159 int error;
160 GLubyte answerBuffer[200];
161 char *answer;
162
163 REQUEST_FIXED_SIZE(xGLXSingleReq, 4)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((4) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (4) + 3) >> 2) != (uint64_t) client
->req_len)) return(16)
;
164
165 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
166 if (!cx) {
167 return error;
168 }
169
170 pc += __GLX_SINGLE_HDR_SIZE8;
171 lsbFirst = *(GLboolean *) (pc + 0);
172
173 glPixelStorei(GL_PACK_LSB_FIRST0x0D01, lsbFirst);
174 __GLX_GET_ANSWER_BUFFER(answer, cl, 128, 1)if (128 < 0) return 16; else if ((128) > sizeof(answerBuffer
)) { int bump; if ((cl)->returnBufSize < (128)+(1)) { (
cl)->returnBuf = (GLbyte*)realloc((cl)->returnBuf, (128
)+(1)); if (!(cl)->returnBuf) { return 11; } (cl)->returnBufSize
= (128)+(1); } answer = (char*)cl->returnBuf; bump = (long
)(answer) % (1); if (bump) answer += (1) - (bump); } else { answer
= (char *)answerBuffer; }
;
175
176 __glXClearErrorOccured();
177 glGetPolygonStipple((GLubyte *) answer);
178
179 if (__glXErrorOccured()) {
180 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
181 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
182 }
183 else {
184 __GLX_BEGIN_REPLY(128)__glXReply.length = (((128)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
185 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
186 __GLX_SEND_BYTE_ARRAY(128)WriteToClient(client, ((((128)*1)+3) & (GLuint)~3), answer
)
;
187 }
188 return Success0;
189}
190
191static int
192GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
193{
194 GLint compsize, compsize2;
195 GLenum format, type, target;
196 GLboolean swapBytes;
197 __GLXcontext *cx;
198 ClientPtr client = cl->client;
199 int error;
200 char *answer, answerBuffer[200];
201 GLint width = 0, height = 0;
202
203 cx = __glXForceCurrent(cl, tag, &error);
204 if (!cx) {
2
Assuming 'cx' is non-null
3
Taking false branch
205 return error;
206 }
207
208 format = *(GLenum *) (pc + 4);
209 type = *(GLenum *) (pc + 8);
210 target = *(GLenum *) (pc + 0);
211 swapBytes = *(GLboolean *) (pc + 12);
212
213 /* target must be SEPARABLE_2D, however I guess we can let the GL
214 barf on this one.... */
215
216 glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH0x8018, &width);
217 glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT0x8019, &height);
218 /*
219 * The two queries above might fail if we're in a state where queries
220 * are illegal, but then width and height would still be zero anyway.
221 */
222 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
223 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
224
225 if ((compsize = safe_pad(compsize)) < 0)
4
Taking false branch
226 return BadLength16;
227 if ((compsize2 = safe_pad(compsize2)) < 0)
5
Taking false branch
228 return BadLength16;
229
230 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
231 __GLX_GET_ANSWER_BUFFER(answer, cl, safe_add(compsize, compsize2), 1)if (safe_add(compsize, compsize2) < 0) return 16; else if (
(safe_add(compsize, compsize2)) > sizeof(answerBuffer)) { int
bump; if ((cl)->returnBufSize < (safe_add(compsize, compsize2
))+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->returnBuf
, (safe_add(compsize, compsize2))+(1)); if (!(cl)->returnBuf
) { return 11; } (cl)->returnBufSize = (safe_add(compsize,
compsize2))+(1); } answer = (char*)cl->returnBuf; bump = (
long)(answer) % (1); if (bump) answer += (1) - (bump); } else
{ answer = (char *)answerBuffer; }
;
6
Within the expansion of the macro '__GLX_GET_ANSWER_BUFFER':
a
Call to 'realloc' has an allocation size of 0 bytes
232 __glXClearErrorOccured();
233 glGetSeparableFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
234 *(GLenum *) (pc + 8), answer, answer + compsize, NULL((void*)0));
235
236 if (__glXErrorOccured()) {
237 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
238 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
239 }
240 else {
241 __GLX_BEGIN_REPLY(compsize + compsize2)__glXReply.length = (((compsize + compsize2)+3) & (GLuint
)~3) >> 2; __glXReply.type = 1; __glXReply.sequenceNumber
= client->sequence;
;
242 ((xGLXGetSeparableFilterReply *) &__glXReply)->width = width;
243 ((xGLXGetSeparableFilterReply *) &__glXReply)->height = height;
244 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
245 __GLX_SEND_VOID_ARRAY(compsize + compsize2)WriteToClient(client, ((((compsize + compsize2)*1)+3) & (
GLuint)~3), answer)
;
246 }
247
248 return Success0;
249}
250
251int
252__glXDisp_GetSeparableFilter(__GLXclientState * cl, GLbyte * pc)
253{
254 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag);
255 ClientPtr client = cl->client;
256 REQUEST_FIXED_SIZE(xGLXSingleReq, 16)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((16) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (16) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
257 return GetSeparableFilter(cl, pc + __GLX_SINGLE_HDR_SIZE8, tag);
258}
259
260int
261__glXDisp_GetSeparableFilterEXT(__GLXclientState * cl, GLbyte * pc)
262{
263 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc)(((xGLXVendorPrivateReq*)pc)->contextTag);
264 ClientPtr client = cl->client;
265 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16)if (((sizeof(xGLXVendorPrivateReq) >> 2) > client->
req_len) || (((16) >> 2) >= client->req_len) || (
(((uint64_t) sizeof(xGLXVendorPrivateReq) + (16) + 3) >>
2) != (uint64_t) client->req_len)) return(16)
;
266 return GetSeparableFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE12, tag);
1
Calling 'GetSeparableFilter'
267}
268
269static int
270GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
271{
272 GLint compsize;
273 GLenum format, type, target;
274 GLboolean swapBytes;
275 __GLXcontext *cx;
276 ClientPtr client = cl->client;
277 int error;
278 char *answer, answerBuffer[200];
279 GLint width = 0, height = 0;
280
281 cx = __glXForceCurrent(cl, tag, &error);
282 if (!cx) {
283 return error;
284 }
285
286 format = *(GLenum *) (pc + 4);
287 type = *(GLenum *) (pc + 8);
288 target = *(GLenum *) (pc + 0);
289 swapBytes = *(GLboolean *) (pc + 12);
290
291 glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH0x8018, &width);
292 if (target == GL_CONVOLUTION_1D0x8010) {
293 height = 1;
294 }
295 else {
296 glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT0x8019, &height);
297 }
298 /*
299 * The two queries above might fail if we're in a state where queries
300 * are illegal, but then width and height would still be zero anyway.
301 */
302 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
303 if (compsize < 0)
304 return BadLength16;
305
306 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
307 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1)if (compsize < 0) return 16; else if ((compsize) > sizeof
(answerBuffer)) { int bump; if ((cl)->returnBufSize < (
compsize)+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->
returnBuf, (compsize)+(1)); if (!(cl)->returnBuf) { return
11; } (cl)->returnBufSize = (compsize)+(1); } answer = (char
*)cl->returnBuf; bump = (long)(answer) % (1); if (bump) answer
+= (1) - (bump); } else { answer = (char *)answerBuffer; }
;
308 __glXClearErrorOccured();
309 glGetConvolutionFilter(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
310 *(GLenum *) (pc + 8), answer);
311
312 if (__glXErrorOccured()) {
313 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
314 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
315 }
316 else {
317 __GLX_BEGIN_REPLY(compsize)__glXReply.length = (((compsize)+3) & (GLuint)~3) >>
2; __glXReply.type = 1; __glXReply.sequenceNumber = client->
sequence;
;
318 ((xGLXGetConvolutionFilterReply *) &__glXReply)->width = width;
319 ((xGLXGetConvolutionFilterReply *) &__glXReply)->height = height;
320 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
321 __GLX_SEND_VOID_ARRAY(compsize)WriteToClient(client, ((((compsize)*1)+3) & (GLuint)~3), answer
)
;
322 }
323
324 return Success0;
325}
326
327int
328__glXDisp_GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc)
329{
330 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag);
331 ClientPtr client = cl->client;
332 REQUEST_FIXED_SIZE(xGLXSingleReq, 16)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((16) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (16) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
333 return GetConvolutionFilter(cl, pc + __GLX_SINGLE_HDR_SIZE8, tag);
334}
335
336int
337__glXDisp_GetConvolutionFilterEXT(__GLXclientState * cl, GLbyte * pc)
338{
339 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc)(((xGLXVendorPrivateReq*)pc)->contextTag);
340 ClientPtr client = cl->client;
341 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16)if (((sizeof(xGLXVendorPrivateReq) >> 2) > client->
req_len) || (((16) >> 2) >= client->req_len) || (
(((uint64_t) sizeof(xGLXVendorPrivateReq) + (16) + 3) >>
2) != (uint64_t) client->req_len)) return(16)
;
342 return GetConvolutionFilter(cl, pc + __GLX_VENDPRIV_HDR_SIZE12, tag);
343}
344
345static int
346GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
347{
348 GLint compsize;
349 GLenum format, type, target;
350 GLboolean swapBytes, reset;
351 __GLXcontext *cx;
352 ClientPtr client = cl->client;
353 int error;
354 char *answer, answerBuffer[200];
355 GLint width = 0;
356
357 cx = __glXForceCurrent(cl, tag, &error);
358 if (!cx) {
359 return error;
360 }
361
362 format = *(GLenum *) (pc + 4);
363 type = *(GLenum *) (pc + 8);
364 target = *(GLenum *) (pc + 0);
365 swapBytes = *(GLboolean *) (pc + 12);
366 reset = *(GLboolean *) (pc + 13);
367
368 glGetHistogramParameteriv(target, GL_HISTOGRAM_WIDTH0x8026, &width);
369 /*
370 * The one query above might fail if we're in a state where queries
371 * are illegal, but then width would still be zero anyway.
372 */
373 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
374 if (compsize < 0)
375 return BadLength16;
376
377 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
378 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1)if (compsize < 0) return 16; else if ((compsize) > sizeof
(answerBuffer)) { int bump; if ((cl)->returnBufSize < (
compsize)+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->
returnBuf, (compsize)+(1)); if (!(cl)->returnBuf) { return
11; } (cl)->returnBufSize = (compsize)+(1); } answer = (char
*)cl->returnBuf; bump = (long)(answer) % (1); if (bump) answer
+= (1) - (bump); } else { answer = (char *)answerBuffer; }
;
379 __glXClearErrorOccured();
380 glGetHistogram(target, reset, format, type, answer);
381
382 if (__glXErrorOccured()) {
383 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
384 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
385 }
386 else {
387 __GLX_BEGIN_REPLY(compsize)__glXReply.length = (((compsize)+3) & (GLuint)~3) >>
2; __glXReply.type = 1; __glXReply.sequenceNumber = client->
sequence;
;
388 ((xGLXGetHistogramReply *) &__glXReply)->width = width;
389 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
390 __GLX_SEND_VOID_ARRAY(compsize)WriteToClient(client, ((((compsize)*1)+3) & (GLuint)~3), answer
)
;
391 }
392
393 return Success0;
394}
395
396int
397__glXDisp_GetHistogram(__GLXclientState * cl, GLbyte * pc)
398{
399 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag);
400 ClientPtr client = cl->client;
401 REQUEST_FIXED_SIZE(xGLXSingleReq, 16)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((16) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (16) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
402 return GetHistogram(cl, pc + __GLX_SINGLE_HDR_SIZE8, tag);
403}
404
405int
406__glXDisp_GetHistogramEXT(__GLXclientState * cl, GLbyte * pc)
407{
408 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc)(((xGLXVendorPrivateReq*)pc)->contextTag);
409 ClientPtr client = cl->client;
410 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16)if (((sizeof(xGLXVendorPrivateReq) >> 2) > client->
req_len) || (((16) >> 2) >= client->req_len) || (
(((uint64_t) sizeof(xGLXVendorPrivateReq) + (16) + 3) >>
2) != (uint64_t) client->req_len)) return(16)
;
411 return GetHistogram(cl, pc + __GLX_VENDPRIV_HDR_SIZE12, tag);
412}
413
414static int
415GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
416{
417 GLint compsize;
418 GLenum format, type, target;
419 GLboolean swapBytes, reset;
420 __GLXcontext *cx;
421 ClientPtr client = cl->client;
422 int error;
423 char *answer, answerBuffer[200];
424
425 cx = __glXForceCurrent(cl, tag, &error);
426 if (!cx) {
427 return error;
428 }
429
430 format = *(GLenum *) (pc + 4);
431 type = *(GLenum *) (pc + 8);
432 target = *(GLenum *) (pc + 0);
433 swapBytes = *(GLboolean *) (pc + 12);
434 reset = *(GLboolean *) (pc + 13);
435
436 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
437 if (compsize < 0)
438 return BadLength16;
439
440 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
441 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1)if (compsize < 0) return 16; else if ((compsize) > sizeof
(answerBuffer)) { int bump; if ((cl)->returnBufSize < (
compsize)+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->
returnBuf, (compsize)+(1)); if (!(cl)->returnBuf) { return
11; } (cl)->returnBufSize = (compsize)+(1); } answer = (char
*)cl->returnBuf; bump = (long)(answer) % (1); if (bump) answer
+= (1) - (bump); } else { answer = (char *)answerBuffer; }
;
442 __glXClearErrorOccured();
443 glGetMinmax(target, reset, format, type, answer);
444
445 if (__glXErrorOccured()) {
446 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
447 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
448 }
449 else {
450 __GLX_BEGIN_REPLY(compsize)__glXReply.length = (((compsize)+3) & (GLuint)~3) >>
2; __glXReply.type = 1; __glXReply.sequenceNumber = client->
sequence;
;
451 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
452 __GLX_SEND_VOID_ARRAY(compsize)WriteToClient(client, ((((compsize)*1)+3) & (GLuint)~3), answer
)
;
453 }
454
455 return Success0;
456}
457
458int
459__glXDisp_GetMinmax(__GLXclientState * cl, GLbyte * pc)
460{
461 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag);
462 ClientPtr client = cl->client;
463 REQUEST_FIXED_SIZE(xGLXSingleReq, 16)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((16) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (16) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
464 return GetMinmax(cl, pc + __GLX_SINGLE_HDR_SIZE8, tag);
465}
466
467int
468__glXDisp_GetMinmaxEXT(__GLXclientState * cl, GLbyte * pc)
469{
470 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc)(((xGLXVendorPrivateReq*)pc)->contextTag);
471 ClientPtr client = cl->client;
472 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16)if (((sizeof(xGLXVendorPrivateReq) >> 2) > client->
req_len) || (((16) >> 2) >= client->req_len) || (
(((uint64_t) sizeof(xGLXVendorPrivateReq) + (16) + 3) >>
2) != (uint64_t) client->req_len)) return(16)
;
473 return GetMinmax(cl, pc + __GLX_VENDPRIV_HDR_SIZE12, tag);
474}
475
476static int
477GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
478{
479 GLint compsize;
480 GLenum format, type, target;
481 GLboolean swapBytes;
482 __GLXcontext *cx;
483 ClientPtr client = cl->client;
484 int error;
485 char *answer, answerBuffer[200];
486 GLint width = 0;
487
488 cx = __glXForceCurrent(cl, tag, &error);
489 if (!cx) {
490 return error;
491 }
492
493 target = *(GLenum *) (pc + 0);
494 format = *(GLenum *) (pc + 4);
495 type = *(GLenum *) (pc + 8);
496 swapBytes = *(GLboolean *) (pc + 12);
497
498 glGetColorTableParameteriv(target, GL_COLOR_TABLE_WIDTH0x80D9, &width);
499 /*
500 * The one query above might fail if we're in a state where queries
501 * are illegal, but then width would still be zero anyway.
502 */
503 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
504 if (compsize < 0)
505 return BadLength16;
506
507 glPixelStorei(GL_PACK_SWAP_BYTES0x0D00, swapBytes);
508 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1)if (compsize < 0) return 16; else if ((compsize) > sizeof
(answerBuffer)) { int bump; if ((cl)->returnBufSize < (
compsize)+(1)) { (cl)->returnBuf = (GLbyte*)realloc((cl)->
returnBuf, (compsize)+(1)); if (!(cl)->returnBuf) { return
11; } (cl)->returnBufSize = (compsize)+(1); } answer = (char
*)cl->returnBuf; bump = (long)(answer) % (1); if (bump) answer
+= (1) - (bump); } else { answer = (char *)answerBuffer; }
;
509 __glXClearErrorOccured();
510 glGetColorTable(*(GLenum *) (pc + 0), *(GLenum *) (pc + 4),
511 *(GLenum *) (pc + 8), answer);
512
513 if (__glXErrorOccured()) {
514 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
515 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
516 }
517 else {
518 __GLX_BEGIN_REPLY(compsize)__glXReply.length = (((compsize)+3) & (GLuint)~3) >>
2; __glXReply.type = 1; __glXReply.sequenceNumber = client->
sequence;
;
519 ((xGLXGetColorTableReply *) &__glXReply)->width = width;
520 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
521 __GLX_SEND_VOID_ARRAY(compsize)WriteToClient(client, ((((compsize)*1)+3) & (GLuint)~3), answer
)
;
522 }
523
524 return Success0;
525}
526
527int
528__glXDisp_GetColorTable(__GLXclientState * cl, GLbyte * pc)
529{
530 const GLXContextTag tag = __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag);
531 ClientPtr client = cl->client;
532 REQUEST_FIXED_SIZE(xGLXSingleReq, 16)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((16) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (16) + 3) >> 2) != (uint64_t)
client->req_len)) return(16)
;
533 return GetColorTable(cl, pc + __GLX_SINGLE_HDR_SIZE8, tag);
534}
535
536int
537__glXDisp_GetColorTableSGI(__GLXclientState * cl, GLbyte * pc)
538{
539 const GLXContextTag tag = __GLX_GET_VENDPRIV_CONTEXT_TAG(pc)(((xGLXVendorPrivateReq*)pc)->contextTag);
540 ClientPtr client = cl->client;
541 REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 16)if (((sizeof(xGLXVendorPrivateReq) >> 2) > client->
req_len) || (((16) >> 2) >= client->req_len) || (
(((uint64_t) sizeof(xGLXVendorPrivateReq) + (16) + 3) >>
2) != (uint64_t) client->req_len)) return(16)
;
542 return GetColorTable(cl, pc + __GLX_VENDPRIV_HDR_SIZE12, tag);
543}