Skip to content

Commit

Permalink
pkcs15.c: Fix memory leak
Browse files Browse the repository at this point in the history
When sc_pkcs15_read_cached_file allocates data pointer
but following sc_select_file fails, the data pointer
is rewritten by another malloc.
  • Loading branch information
xhanulik committed May 16, 2024
1 parent ea4b217 commit 9a484a9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/libopensc/pkcs15.c
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,7 @@ sc_pkcs15_read_file(struct sc_pkcs15_card *p15card, const struct sc_path *in_pat
}
}

free(data);
data = malloc(len);
if (data == NULL) {
r = SC_ERROR_OUT_OF_MEMORY;
Expand Down

0 comments on commit 9a484a9

Please sign in to comment.