mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
g10: Make call to agent_scd_serialno more robust.
* g10/call-agent.c (agent_scd_serialno): Make sure that NULL is stored on error at r_serialno. * g10/card-util.c (card_status): Simplify freeing of seriaono. (factory_reset): Ditto. -- This pattern is what we use with other functions returning an allocated string and thus less surprising.
This commit is contained in:
parent
cf4b8a27c3
commit
0f780b1aeb
@ -1381,6 +1381,7 @@ agent_scd_serialno (char **r_serialno, const char *demand)
|
||||
char *serialno = NULL;
|
||||
char line[ASSUAN_LINELENGTH];
|
||||
|
||||
*r_serialno = NULL;
|
||||
err = start_agent (NULL, (1 | FLAG_FOR_CARD_SUPPRESS_ERRORS));
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -688,7 +688,8 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
||||
{
|
||||
int err;
|
||||
strlist_t card_list, sl;
|
||||
char *serialno0, *serialno1;
|
||||
char *serialno0 = NULL;
|
||||
char *serialno1 = NULL;
|
||||
int all_cards = 0;
|
||||
int any_card = 0;
|
||||
|
||||
@ -733,6 +734,7 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
||||
|
||||
current_card_status (ctrl, fp, NULL, 0);
|
||||
xfree (serialno1);
|
||||
serialno1 = NULL;
|
||||
|
||||
if (!all_cards)
|
||||
goto leave;
|
||||
@ -740,11 +742,10 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
||||
|
||||
/* Select the original card again. */
|
||||
err = agent_scd_serialno (&serialno1, serialno0);
|
||||
if (!err)
|
||||
xfree (serialno1);
|
||||
|
||||
leave:
|
||||
xfree (serialno0);
|
||||
xfree (serialno1);
|
||||
free_strlist (card_list);
|
||||
}
|
||||
|
||||
@ -2000,8 +2001,7 @@ factory_reset (void)
|
||||
char *serialno0;
|
||||
|
||||
err = agent_scd_serialno (&serialno0, NULL);
|
||||
if (!err)
|
||||
xfree (serialno0);
|
||||
xfree (serialno0);
|
||||
}
|
||||
|
||||
leave:
|
||||
|
Loading…
x
Reference in New Issue
Block a user