[Spice-devel] [PATCH libcacard] Use proper free function for PK11_ReadRawAttribute call

Christophe Fergeau cfergeau at redhat.com
Wed Aug 22 08:13:45 UTC 2018


Looks good to me,
Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Wed, Aug 15, 2018 at 10:30:38AM +0100, Frediano Ziglio wrote:
> As documented in PK11_ReadRawAttribute data should be freed with
> PORT_Free, not free or g_free.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/vcard_emul_nss.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/vcard_emul_nss.c b/src/vcard_emul_nss.c
> index 9658c5a..43707d0 100644
> --- a/src/vcard_emul_nss.c
> +++ b/src/vcard_emul_nss.c
> @@ -1312,6 +1312,7 @@ vcard_emul_read_object(VCard *card, const char *label,
>      PK11GenericObject *obj, *firstObj, *myObj = NULL;
>      SECItem result;
>      SECStatus r;
> +    unsigned char *ret;
>  
>      slot = vcard_emul_card_get_slot(card);
>  
> @@ -1330,7 +1331,7 @@ vcard_emul_read_object(VCard *card, const char *label,
>              && memcmp(label, result.data, result.len) == 0)
>              found = 1;
>  
> -        free(result.data);
> +        PORT_Free(result.data);
>          result.data = NULL;
>  
>          if (found) {
> @@ -1351,8 +1352,9 @@ vcard_emul_read_object(VCard *card, const char *label,
>          return NULL;
>  
>      *ret_len = result.len;
> -    return result.data;
> -
> +    ret = g_memdup(result.data, result.len);
> +    PORT_Free(result.data);
> +    return ret;
>  }
>  
>  void
> -- 
> 2.17.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180822/d9e124c9/attachment.sig>


More information about the Spice-devel mailing list