Skip to content

Commit b02c3c7

Browse files
authored
Merge pull request #150 from GregThain/fix-memory-leaks
Fix memory leaks in rs256_from_coords
2 parents 6612085 + f912c2d commit b02c3c7

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/scitokens_internal.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,6 @@ std::string rs256_from_coords(const std::string &e_str,
527527
throw UnsupportedKeyException("Failed to serialize RSA public key");
528528
}
529529
#endif
530-
e_bignum.release();
531-
n_bignum.release();
532530

533531
char *mem_data;
534532
size_t mem_len = BIO_get_mem_data(pubkey_bio.get(), &mem_data);
@@ -960,12 +958,12 @@ bool scitokens::Validator::store_public_ec_key(const std::string &issuer,
960958
"Unable to get OpenSSL public key parameters");
961959
}
962960

963-
void *buf = NULL;
964-
size_t buf_len, max_len = 256;
961+
const void *buf = NULL;
962+
size_t buf_len;
965963
OSSL_PARAM *p = OSSL_PARAM_locate(params, "pub");
966-
if (!p || !OSSL_PARAM_get_octet_string(p, &buf, max_len, &buf_len) ||
964+
if (!p || !OSSL_PARAM_get_octet_string_ptr(p, &buf, &buf_len) ||
967965
!EC_POINT_oct2point(ec_group.get(), q_point.get(),
968-
static_cast<unsigned char *>(buf), buf_len,
966+
static_cast<const unsigned char *>(buf), buf_len,
969967
nullptr)) {
970968
throw UnsupportedKeyException(
971969
"Failed to to set OpenSSL EC point with public key information");

src/verify.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ int main(int argc, char *const *argv) {
123123
std::cout << "Failed to deserialize a token: " << err_msg << std::endl;
124124
return 1;
125125
}
126+
scitoken_destroy(scitoken);
126127
std::cout << "Token deserialization successful." << std::endl;
127128

128129
return 0;

0 commit comments

Comments
 (0)