diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c index 6e774894..da8f53d4 100644 --- a/src/tools/pkcs11-tool.c +++ b/src/tools/pkcs11-tool.c @@ -750,7 +750,7 @@ get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount) \ \ rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \ if (rv == CKR_OK) { \ - if (!(attr.pValue = malloc(attr.ulValueLen))) \ + if (!(attr.pValue = calloc(1, attr.ulValueLen + 1))) \ fatal("out of memory in get" #ATTR ": %m"); \ rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \ } \