From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Unnecessary pointer-NULL checks in pgp-pgsql.c |
Date: | 2015-02-02 02:14:14 |
Message-ID: | CAB7nPqRE25Xi15A-dpS4OW7VCNyyf0F3OWBNc0CSCLd_KM5G9Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
Coverity is pointing out that we are doing pointer-NULL checks on
things that cannot be NULL in decrypt_internal():
out:
- if (src)
- mbuf_free(src);
- if (ctx)
- pgp_free(ctx);
+ Assert(ctx != NULL && src != NULL && dst != NULL);
+ mbuf_free(src);
+ pgp_free(ctx);
if (err)
{
px_set_debug_handler(NULL);
- if (dst)
- mbuf_free(dst);
+ mbuf_free(dst);
src, dst and ctx are created respectively from mbuf_create_from_data,
mbuf_create and pgp_init which never return NULL and they are palloc'd
all the time. I think that we could simplify things with the patch
attached, note that I added an assertion for correctness but I don't
really think that it is much necessary.
Regards,
--
Michael
Attachment | Content-Type | Size |
---|---|---|
20150202_pgcrypto_fixes.patch | text/x-diff | 671 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2015-02-02 03:59:11 | Re: WIP: dynahash replacement for buffer table |
Previous Message | Michael Paquier | 2015-02-02 01:39:31 | Some dead code in metaphone() of fuzzystrmatch.c |