Re: Warning on contrib/tsearch2 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Warning on contrib/tsearch2
Date
Msg-id 12778.1175045686@sss.pgh.pa.us
Whole thread Raw
In response to Warning on contrib/tsearch2  (Neil Conway <neilc@samurai.com>)
Responses Re: Warning on contrib/tsearch2
Re: Warning on contrib/tsearch2
List pgsql-hackers
Neil Conway <neilc@samurai.com> writes:
> In CVS HEAD:
> contrib/tsearch2/dict_syn.c:124: warning: 'slen' is used uninitialized 
> in this function
> Induced by the recent pg_verifymbstr() patch.

Seems to be a genuine bug.  Fixed, but I see a worse problem with this
code: random backend code should not, not, not be using fopen()
directly.  If you lose control to an elog, which is certainly possible
seeing that this loop calls into the utils/mb subsystem, you'll leak
the file descriptor.  Use AllocateFile/FreeFile instead of fopen/fclose.

I find the direct use of malloc/realloc/strdup to be poor style as well
--- backend code that is not using palloc needs to have *very* good
reason to do so, and I see none here.

I'm halfway tempted to change postgres.h to #define these functions to
yield errors, and only allow #undef'ing them in the files that are
supposed to access the C library functions directly.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_index updates and SI invalidation
Next
From: Koichi Suzuki
Date:
Subject: Re: [PATCHES] Full page writes improvement, code update