diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c index 6558593a..2cf40ff9 100644 --- a/src/tools/pkcs15-init.c +++ b/src/tools/pkcs15-init.c @@ -1798,8 +1798,11 @@ get_pin_callback(struct sc_profile *profile, allocated = 1; } - if (len > *pinsize) + if (len > *pinsize) { + if (allocated) + free(secret); return SC_ERROR_BUFFER_TOO_SMALL; + } memcpy(pinbuf, secret, len + 1); *pinsize = len; if (allocated)