Re: [HACKERS] Small fix: avoid passing null pointers to memcpy()

From: didier <did447(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Small fix: avoid passing null pointers to memcpy()
Date: 2019-05-24 16:19:12
Message-ID: CAJRYxu+5wNP8JcxbvE4hzB47vHO4XQxbxG5ZFbZ5ADe78p_gOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, May 24, 2019 at 5:10 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> didier <did447(at)gmail(dot)com> writes:
> > A smaller version removing memset in print_aligned_text function.
> > The line is redundant , header_done isn't used yet and it's either
> > pg_malloc0 or null.
>
> Hm, I see the theoretical problem ...
>
> > Without this patch make check fails 3 tests if pg is compiled with
> > -fsanitize=address,undefined
>
> ... but if that's the only evidence of an actual problem, I can't
> get excited about it. ASAN complains about many things in Postgres,
Not that much, make check has only this one.

> and most of them are pretty hypothetical.
Well there's no point for this line even without ASAN, why call memset
on header_done but not on width_header,
width_average, and so on?

ASAN complaining at runtime because memset is called with a null ptr
and a zero count is just the nudge for removing it.

Regards
Didier

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-05-24 16:24:28 Re: [HACKERS] Runtime Partition Pruning
Previous Message Tom Lane 2019-05-24 16:08:57 Re: [HACKERS] Runtime Partition Pruning