From 9a484a9d22368d2a0baad05ea6049e4c3d5e8cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Veronika=20Hanul=C3=ADkov=C3=A1?= Date: Tue, 14 May 2024 10:11:56 +0200 Subject: [PATCH] pkcs15.c: Fix memory leak When sc_pkcs15_read_cached_file allocates data pointer but following sc_select_file fails, the data pointer is rewritten by another malloc. --- src/libopensc/pkcs15.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index bb03ac7ec6..3f3198d3bc 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -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;