On Thu, Sep 03, 2020 at 07:03:14AM +0200, Theo Buehler wrote:

> The memset is not needed as recallocarray(3) does the zeroing already.
> (I also think the a->data == NULL check in the if clause is redundant,
> but I'm just suggesting to remove a bit that confused me)

ok,

        -Otto

> 
> Index: asn1/a_bitstr.c
> ===================================================================
> RCS file: /var/cvs/src/lib/libcrypto/asn1/a_bitstr.c,v
> retrieving revision 1.29
> diff -u -p -U7 -r1.29 a_bitstr.c
> --- asn1/a_bitstr.c   20 Oct 2018 16:07:09 -0000      1.29
> +++ asn1/a_bitstr.c   15 Jun 2020 12:46:00 -0000
> @@ -211,16 +211,14 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING 
>       if ((a->length < (w + 1)) || (a->data == NULL)) {
>               if (!value)
>                       return(1); /* Don't need to set */
>               if ((c = recallocarray(a->data, a->length, w + 1, 1)) == NULL) {
>                       ASN1error(ERR_R_MALLOC_FAILURE);
>                       return 0;
>               }
> -             if (w + 1 - a->length > 0)
> -                     memset(c + a->length, 0, w + 1 - a->length);
>               a->data = c;
>               a->length = w + 1;
>       }
>       a->data[w] = ((a->data[w]) & iv) | v;
>       while ((a->length > 0) && (a->data[a->length - 1] == 0))
>               a->length--;
>  
> 

Reply via email to