Re: Warning on contrib/tsearch2

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <neilc(at)samurai(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Subject: Re: Warning on contrib/tsearch2
Date: 2007-03-28 02:15:13
Message-ID: 4609CFB1.9080303@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Neil Conway <neilc(at)samurai(dot)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.
>

Does that apply to things like plperlu?

> 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.
>
>
>

not a bad idea :-)

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2007-03-28 02:48:05 Re: pg_index updates and SI invalidation
Previous Message Koichi Suzuki 2007-03-28 01:54:11 Re: [PATCHES] Full page writes improvement, code update