Possible null pointer dereference in afterTriggerAddEvent() - Mailing list pgsql-hackers

From Alexander Kuznetsov
Subject Possible null pointer dereference in afterTriggerAddEvent()
Date
Msg-id 6d0323c3-3f5d-4137-af73-98a5ab90e77c@altlinux.org
Whole thread Raw
Responses Re: Possible null pointer dereference in afterTriggerAddEvent()
List pgsql-hackers
Hello everyone,

In src/backend/commands/trigger.c:4031, there is an afterTriggerAddEvent() function. The variable chunk is assigned the
valueof events->tail at line 4050. Subsequently, chunk is compared to NULL at lines 4051 and 4079, indicating that
events->tailcould potentially be NULL.
 

However, at line 4102, we dereference events->tail by accessing events->tail->next without first checking if it is
NULL.

To address this issue, I propose at least adding an assertion to ensure that events->tail != NULL before the
dereference.The suggested patch is included in the attachment.
 

-- 
Best regards,
Alexander Kuznetsov
Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Add 64-bit XIDs into PostgreSQL 15
Next
From: Peter Eisentraut
Date:
Subject: Re: add function argument names to regex* functions.