[Mesa-dev] [PATCH] intel: Add a null pointer check before dereferencing the pointer
Anuj Phogat
anuj.phogat at gmail.com
Tue Apr 16 15:49:07 PDT 2013
On Tue, Apr 16, 2013 at 3:06 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Tue, Apr 16, 2013 at 11:11 AM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
>>
>> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
>> ---
>> src/mesa/drivers/dri/intel/intel_screen.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
>> index 16750f2..27b992c 100644
>> --- a/src/mesa/drivers/dri/intel/intel_screen.c
>> +++ b/src/mesa/drivers/dri/intel/intel_screen.c
>> @@ -707,6 +707,9 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
>> stride = parent->strides[index];
>>
>> image = intel_allocate_image(dri_format, loaderPrivate);
>> + if (image == NULL)
>> + return NULL;
>> +
>> if (offset + height * stride > parent->region->bo->size) {
>> _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
>> free(image);
>> --
>> 1.8.1.4
>
> There is another place in the same file that the return value of
> intel_allocate_image isn't checked. Should probably add a check there
> while you're fixing this.
Yeah, there are 2 such places. They are listed under id 463, 464 in the
static analysis tool. I'm not sure why they were not listed under 'to be fixed'
issues. I'll update my patch by adding relevant checks.
More information about the mesa-dev
mailing list