Skip to content

Commit

Permalink
Fix GCC compilation -Waggressive-loop-optimizations
Browse files Browse the repository at this point in the history
GCC 13.1.0 were reporting a compilation warning with -O2/3 and
-Waggressive-loop-optimizations. GCC is raising an undefined behavior in the
while loop. Replace the while loop with a memset call at the top of the
function.

Fixes #21088

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from #23898)
  • Loading branch information
adrien-zinger authored and nhorman committed Apr 2, 2024
1 parent 5673680 commit c45ca06
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions crypto/bn/rsaz_exp_x2.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,7 @@ static void to_words52(BN_ULONG *out, int out_len,
out_len--;
}

while (out_len > 0) {
*out = 0;
out_len--;
out++;
}
memset(out, 0, out_len * sizeof(BN_ULONG));
}

static ossl_inline void put_digit(uint8_t *out, int out_len, uint64_t digit)
Expand Down

0 comments on commit c45ca06

Please sign in to comment.