[Mesa-dev] [PATCH 3/3] mesa: add missing error checks in _mesa_GetObject[Ptr]Label()
Brian Paul
brianp at vmware.com
Mon Sep 16 08:13:01 PDT 2013
Hmm, check out the man page at http://www.opengl.org/sdk/docs/man/xhtml
In the description it basically says that bufSize can be zero, but in
the "Errors" section is says bufSize=0 is a GL_INVALID_VALUE.
I think you're right about bufSize=0 being OK since one might want to
just query the length of the label without actually getting it.
Most GL functions with GLsizei parameters error-check them for negative
or <=0 and raise GL_INVALID_VALUE.
I'll revise my patch for < 0 and file a spec bug report.
-Brian
On 09/16/2013 03:40 AM, Timothy Arceri wrote:
> I tested on Catalyst and it allows both negative and 0 buf size without
> a GL_INVALID_VALUE error.
>
> I'm not sure if I'm allowed to review patches but for whats its worth
> for the other two patches.
>
> Reviewed-by: Timothy Arceri <t_arceri at yahoo.com.au>
>
> On 16/09/13 15:37, Timothy Arceri wrote:
>> Hi Brian,
>>
>> Maybe its just another oversight in the spec but I thought I'd point
>> out that the spec doesnt actually say to test for this in the get
>> label functions. I assumed this was because label can be NULL in which
>> case a bufSize of 0 would be valid. I haven't checked what the
>> Catalyst drivers do yet.
>>
>> Tim
>>
>>
>>
>>> ----- Original Message -----
>>> From: Brian Paul <brianp at vmware.com>
>>> To: mesa-dev at lists.freedesktop.org
>>> Cc:
>>> Sent: Sunday, 15 September 2013 2:16 AM
>>> Subject: [Mesa-dev] [PATCH 3/3] mesa: add missing error checks in
>>> _mesa_GetObject[Ptr]Label()
>>>
>>> ---
>>> src/mesa/main/objectlabel.c | 12 ++++++++++++
>>> 1 file changed, 12 insertions(+)
>>>
>>> diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c
>>> index bfe9ba2..c373a46 100644
>>> --- a/src/mesa/main/objectlabel.c
>>> +++ b/src/mesa/main/objectlabel.c
>>> @@ -256,6 +256,12 @@ _mesa_GetObjectLabel(GLenum identifier, GLuint
>>> name, GLsizei bufSize,
>>> GET_CURRENT_CONTEXT(ctx);
>>> char **labelPtr;
>>>
>>> + if (bufSize <= 0) {
>>> + _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectLabel(bufSize =
>>> %d)",
>>> + bufSize);
>>> + return;
>>> + }
>>> +
>>> labelPtr = get_label_pointer(ctx, identifier, name,
>>> "glGetObjectLabel");
>>> if (!labelPtr)
>>> return;
>>> @@ -288,6 +294,12 @@ _mesa_GetObjectPtrLabel(const void *ptr, GLsizei
>>> bufSize, GLsizei *length,
>>> char **labelPtr;
>>> struct gl_sync_object *const syncObj = (struct gl_sync_object *)
>>> ptr;
>>>
>>> + if (bufSize <= 0) {
>>> + _mesa_error(ctx, GL_INVALID_VALUE,
>>> "glGetObjectPtrLabel(bufSize = %d)",
>>> + bufSize);
>>> + return;
>>> + }
>>> +
>>> if (!_mesa_validate_sync(ctx, syncObj)) {
>>> _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectPtrLabel (not
>>> a valid sync object)");
>>> return;
>>> --
>>> 1.7.10.4
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list