Re: BUG #16188: The usage of NULL pointer in rege_dfa.c

Tom Lane <[email protected]> Sun, 05 Jan 2020 23:09:01 -0500
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
PG Bug reporting form <[email protected]> writes:
> We checked the code in file =E2=80=9Crege_dfa.c=E2=80=9D and there is on=
e error occurring in
> line 481. This error is caused by the usage of pointer with NULL value. =
The
> code in this line is =E2=80=9Cd->work =3D &d->statesarea[nss * wordsper]=
;=E2=80=9D We checked
> the code two lines before the error occurred line and the code is
> =E2=80=9Cd->statesarea =3D (unsigned *) MALLOC((nss + WORK) * wordsper
> *sizeof(unsigned));=E2=80=9D. We found the code hasn=E2=80=99t checked w=
eather the process
> =E2=80=9CMALLOC=E2=80=9D is success or not which directly define the val=
ue of the
> =E2=80=9Cstatesarea=E2=80=9D field of pointer =E2=80=9Cd=E2=80=9D.

I don't see any bug there.  If the malloc for statesarea fails, the
code will exit a few lines further down, without ever having dereferenced
d->work.  So whether d->work is a valid pointer or not is irrelevant.

			regards, tom lane