Avoid passing out-of-bound pointers to 0-size memcpy

Doing so could be considered UB in a strict reading of the standard.
Avoid it.
This commit is contained in:
Pieter Wuille
2021-01-23 21:54:46 -08:00
parent f2d9aeae6d
commit 9570f674cc
3 changed files with 4 additions and 4 deletions

View File

@@ -140,7 +140,7 @@ static int secp256k1_der_parse_integer(secp256k1_scalar *r, const unsigned char
overflow = 1;
}
if (!overflow) {
memcpy(ra + 32 - rlen, *sig, rlen);
if (rlen) memcpy(ra + 32 - rlen, *sig, rlen);
secp256k1_scalar_set_b32(r, ra, &overflow);
}
if (overflow) {