From 49394323043a1f4c37497c32c43a0633453fd645 Mon Sep 17 00:00:00 2001 From: Peter Marschall Date: Thu, 2 Jun 2011 10:10:48 +0200 Subject: [PATCH] OpenPGP: unlink blob from blob tree in pgp_free_blob() Remove links pointing to the blob to be deleted from other blobs in the blob tree structure, so that removing a subordinate blob does not hurt its parent or siblings. Signed-off-by: Peter Marschall --- src/libopensc/card-openpgp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c index d155913c..ef9c491a 100644 --- a/src/libopensc/card-openpgp.c +++ b/src/libopensc/card-openpgp.c @@ -527,6 +527,16 @@ static void pgp_free_blob(struct blob *blob) { if (blob) { + if (blob->parent) { + struct blob **p; + + /* remove blob from list of parent's children */ + for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next) + ; + if (*p == blob) + *p = blob->next; + } + if (blob->file) sc_file_free(blob->file); if (blob->data)