From 2087b149d9a63eac15bbe9f03b0550d17d83eedb Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Sat, 5 Mar 2022 08:58:51 +0100 Subject: FS: Fix segfault in URI handling --- src/fs/fs_uri.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 299dc3159..dff94ee26 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c @@ -644,6 +644,7 @@ struct GNUNET_FS_Uri * GNUNET_FS_uri_parse (const char *uri, char **emsg) { struct GNUNET_FS_Uri *ret; + char *msg; if (NULL == uri) { @@ -655,20 +656,25 @@ GNUNET_FS_uri_parse (const char *uri, char **emsg) /** * FIXME: Do we want to log this? */ - *emsg = NULL; - if (NULL != (ret = uri_chk_parse (uri, emsg))) + msg = NULL; + if (NULL != (ret = uri_chk_parse (uri, &msg))) return ret; - GNUNET_free (*emsg); - if (NULL != (ret = uri_ksk_parse (uri, emsg))) + if (NULL != msg) + GNUNET_free (msg); + if (NULL != (ret = uri_ksk_parse (uri, &msg))) return ret; - GNUNET_free (*emsg); - if (NULL != (ret = uri_sks_parse (uri, emsg))) + if (NULL != msg) + GNUNET_free (msg); + if (NULL != (ret = uri_sks_parse (uri, &msg))) return ret; - GNUNET_free (*emsg); - if (NULL != (ret = uri_loc_parse (uri, emsg))) + if (NULL != msg) + GNUNET_free (msg); + if (NULL != (ret = uri_loc_parse (uri, &msg))) return ret; - GNUNET_free (*emsg); - *emsg = GNUNET_strdup (_ ("Unrecognized URI type")); + if (NULL != msg) + GNUNET_free (msg); + if (NULL != emsg) + *emsg = GNUNET_strdup (_ ("Unrecognized URI type")); return NULL; } -- cgit v1.2.3