From e5ab11607281b9838da2728268a8f9f0daa2b04d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 12 Aug 2014 17:42:08 +0200 Subject: [PATCH] gpgme-tool: Fix segv for external key listing. * src/gpgme-tool.c (result_xml_escape): Allow for DATA being NULL. --- src/gpgme-tool.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index f02fffa7..e1fd9832 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -831,14 +831,17 @@ result_xml_escape (const char *data, char **buf) membuf_t mb; init_membuf (&mb, 128); - data_len = strlen (data); - for (i = 0; i < data_len; i++) + if (data) { - r = result_xml_escape_replacement (data[i]); - if (r) - put_membuf (&mb, r, strlen (r)); - else - put_membuf (&mb, data+i, 1); + data_len = strlen (data); + for (i = 0; i < data_len; i++) + { + r = result_xml_escape_replacement (data[i]); + if (r) + put_membuf (&mb, r, strlen (r)); + else + put_membuf (&mb, data+i, 1); + } } put_membuf (&mb, "", 1); *buf = get_membuf (&mb, NULL);