Skip to content

Commit

Permalink
Fix error handling on strdup (OpenSC#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmorgner committed Feb 1, 2024
1 parent a0eb055 commit 5c6ee99
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pkcs15init/pkcs15-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,13 @@ sc_pkcs15init_add_app(struct sc_card *card, struct sc_profile *profile,
}

if (args->label) {
if (p15card->tokeninfo->label)
free(p15card->tokeninfo->label);
free(p15card->tokeninfo->label);
p15card->tokeninfo->label = strdup(args->label);
}
app->label = strdup(p15card->tokeninfo->label);
if (p15card->tokeninfo->label)
app->label = strdup(p15card->tokeninfo->label);
else
app->label = strdup("Token");

/* See if we've set an SO PIN */
r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_AODF, pin_obj);
Expand Down

0 comments on commit 5c6ee99

Please sign in to comment.