Skip to content

Commit

Permalink
Avoid memory leak if SXNET_add_id_INTEGER() fails
Browse files Browse the repository at this point in the history
Fixes Coverity 1560046

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from #23211)

(cherry picked from commit 7054fc1)
  • Loading branch information
t8m committed Jan 8, 2024
1 parent a43f253 commit 1c75ba9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crypto/x509/v3_sxnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userle
ERR_raise(ERR_LIB_X509V3, X509V3_R_ERROR_CONVERTING_ZONE);
return 0;
}
return SXNET_add_id_INTEGER(psx, izone, user, userlen);
if (!SXNET_add_id_INTEGER(psx, izone, user, userlen)) {
ASN1_INTEGER_free(izone);
return 0;
}
return 1;
}

/* Add an id given the zone as an unsigned long */
Expand All @@ -139,8 +143,11 @@ int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user,
ASN1_INTEGER_free(izone);
return 0;
}
return SXNET_add_id_INTEGER(psx, izone, user, userlen);

if (!SXNET_add_id_INTEGER(psx, izone, user, userlen)) {
ASN1_INTEGER_free(izone);
return 0;
}
return 1;
}

/*
Expand Down

0 comments on commit 1c75ba9

Please sign in to comment.