>
> hash = (text *)palloc(hlen+1);
??? palloc(hlen + VARHDRSZ)
>
> memset(VARDATA(hash), 0, hlen);
> SHA512(VARDATA(plain), hlen, VARDATA(hash));
++ VARATT_SIZEP (hash) = VARHDRSZ + ....;
> PG_RETURN_TEXT_P(hash);
> }
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>