Skip to content

Commit

Permalink
Change condition to avoid spurious compiler complaints.
Browse files Browse the repository at this point in the history
X509_TRUST_get0() is checking < 0, the code here was checking == -1.  Both are
equivalent in this situation but gcc-12 has conniptions about a subsequent
possible NULL dereference (which isn't possible).

Fixes #17665

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #17668)
  • Loading branch information
paulidale committed Feb 11, 2022
1 parent 378c50f commit b84c6e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/x509/x509_trust.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
/* Get existing entry if any */
idx = X509_TRUST_get_by_id(id);
/* Need a new entry */
if (idx == -1) {
if (idx < 0) {
if ((trtmp = OPENSSL_malloc(sizeof(*trtmp))) == NULL) {
ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE);
return 0;
Expand Down

0 comments on commit b84c6e8

Please sign in to comment.