From 293001e2c6f0e228ff7f1b6a3e2606ae1370a5d5 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 18 Sep 2018 09:34:00 +0900 Subject: [PATCH] g10: Fix memory leak for --card-status. * g10/card-util.c (card_status): Release memory of serial number. -- Cherry pick of master commit: fe8b6339542f3b1228b5fd56fc710ea3b07a3a2b Signed-off-by: NIIBE Yutaka --- g10/card-util.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/g10/card-util.c b/g10/card-util.c index 52a09b582..dc4c0e646 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -667,7 +667,7 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno) { int err; strlist_t card_list, sl; - char *serialno0; + char *serialno0, *serialno1; int all_cards = 0; if (serialno == NULL) @@ -693,8 +693,6 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno) for (sl = card_list; sl; sl = sl->next) { - char *serialno1; - if (!all_cards && strcmp (serialno, sl->d)) continue; @@ -715,7 +713,8 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno) } /* Select the original card again. */ - err = agent_scd_serialno (&serialno0, serialno0); + err = agent_scd_serialno (&serialno1, serialno0); + xfree (serialno1); leave: xfree (serialno0);