fixed coverity issues

- CID 145623 (#1 of 1): Resource leak (RESOURCE_LEAK)
- CID 269069 (#1 of 1): Resource leak (RESOURCE_LEAK)
- CID undefined (#1 of 1): Dereference before null check (REVERSE_INULL)
This commit is contained in:
Frank Morgner 2018-04-07 12:11:13 +02:00
parent e1bc515363
commit 148bc25238
3 changed files with 5 additions and 2 deletions

View File

@ -158,8 +158,10 @@ static void print_hex(const u8 * buf, size_t buflen, size_t depth)
char *lines = malloc(lines_len);
char *line = lines;
if (buf == NULL || buflen == 0 || lines == NULL)
if (buf == NULL || buflen == 0 || lines == NULL) {
free(lines);
return;
}
sc_hex_dump(buf, buflen, lines, lines_len);

View File

@ -808,6 +808,7 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
set_defaults(ctx, &opts);
if (0 != list_init(&ctx->readers)) {
sc_release_context(ctx);
return SC_ERROR_OUT_OF_MEMORY;
}
list_attributes_seeker(&ctx->readers, reader_list_seeker);

View File

@ -1618,7 +1618,7 @@ pkcs15_login(struct sc_pkcs11_slot *slot, CK_USER_TYPE userType,
}
}
if (userType == CKU_CONTEXT_SPECIFIC && pin_info) {
if (userType == CKU_CONTEXT_SPECIFIC) {
int auth_meth_saved = pin_info->auth_method;
sc_log(context, "Setting SC_AC_CONTEXT_SPECIFIC");