Skip to content

Commit

Permalink
Fix null
Browse files Browse the repository at this point in the history
The function should return null in case the data is null, for consistency with existing hashing functions like md5, digest, etc
  • Loading branch information
dmitrystas authored Jun 17, 2023
1 parent 80f8b00 commit 7af522e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pg_blake2b.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ pg_blake2b(PG_FUNCTION_ARGS)

bytea *digest;
bytea *key = NULL;
bytea *data = PG_GETARG_BYTEA_PP(0);
bytea *data;

size_t keylen = 0;
size_t datalen = VARSIZE(data) - VARHDRSZ;
size_t datalen;

int16 digest_size = BLAKE2B_OUTBYTES;

if (PG_ARGISNULL(0))
{
PG_RETURN_NULL();
}

data = PG_GETARG_BYTEA_PP(0);
datalen = VARSIZE(data) - VARHDRSZ;

if (!PG_ARGISNULL(1))
{
digest_size = PG_GETARG_INT16(1);
Expand Down

0 comments on commit 7af522e

Please sign in to comment.