Re: Fix memcmp() with different sizes. - Mailing list pgsql-patches

From Tom Lane
Subject Re: Fix memcmp() with different sizes.
Date
Msg-id 9475.1075775266@sss.pgh.pa.us
Whole thread Raw
In response to Fix memcmp() with different sizes.  (Kurt Roeckx <Q@ping.be>)
Responses Re: Fix memcmp() with different sizes.  (Kurt Roeckx <Q@ping.be>)
List pgsql-patches
Kurt Roeckx <Q@ping.be> writes:
> -        if (memcmp(re_array[i].cre_pat, text_re, text_re_len) == 0 &&
> +        if (VARSIZE(re_array[i].cre_pat) == text_re_len &&
> +        memcmp(re_array[i].cre_pat, text_re, text_re_len) == 0 &&

This is not actually broken.  The first four bytes of what memcmp is
comparing are the length, and so it'll fall out immediately anyway if
the lengths differ.

            regards, tom lane

pgsql-patches by date:

Previous
From: Claudio Natoli
Date:
Subject: Re: [pgsql-hackers-win32] Proposed dirmod.c fix for Win
Next
From: Tom Lane
Date:
Subject: Re: fix memcpy() overlap