Commit 369e9339 authored by Kurt Roeckx's avatar Kurt Roeckx
Browse files

Avoid calling memcpy with lenght of 0



We can call memcpy() with a pointer 1 past the last allocated byte and length
of 0 and you can argue that that's undefined behaviour.

Reported by tis-interpreter

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>

GH: #1132
parent 4379d5ce
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -66,10 +66,11 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)

    *(p++) = (unsigned char)bits;
    d = a->data;
    if (len > 0) {
        memcpy(p, d, len);
        p += len;
    if (len > 0)
        p[-1] &= (0xff << bits);
    }
    *pp = p;
    return (ret);
}