Re: C Extension woes - Mailing list pgsql-hackers

From Andrew Chernow
Subject Re: C Extension woes
Date
Msg-id 48A2C327.7060900@esilo.com
Whole thread Raw
In response to C Extension woes  (Tim Hawes <thawes@novadine.com>)
Responses Re: C Extension woes  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: C Extension woes  (Tim Hawes <thawes@novadine.com>)
List pgsql-hackers
Tim Hawes wrote:
> 
> text * pl_masterkey(PG_FUNCTION_ARGS)
> {
>  char *e_var = getenv("PGMASTERKEY");
>  size_t length = VARSIZE(e_var) - VARHDRSZ;
> 
> 

The VARSIZE macro is for variable length structures, like a text or 
bytea which contains a length and data member.  You are using this macro 
on a regular C string "e_var".  Try this instead:

size_t length = e_var != NULL ? strlen(e_var) : 0;

-- 
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Replay attack of query cancel
Next
From: "Dmitry Koterov"
Date:
Subject: Patch: propose to include 3 new functions into intarray and intagg