From c55c08bd1e45ea3ce5f4a659344e0bbb0ad8c294 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 26 Feb 2019 09:25:04 +0100 Subject: [PATCH] fix profiler crash on bad startup --- src/rps/gnunet-rps-profiler.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 8e6fa389a..cdf555432 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -2831,7 +2831,8 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); cur_test_run.name = "test-rps-profiler"; - if (0 == num_peers) num_peers = 10; + if (0 == num_peers) + num_peers = 10; mal_type = 3; cur_test_run.init_peer = profiler_init_peer; //cur_test_run.pre_test = mal_pre; @@ -2957,25 +2958,21 @@ main (int argc, char *argv[]) "COUNT", gettext_noop ("number of peers to start"), &num_peers), - GNUNET_GETOPT_option_relative_time ('d', "duration", "DURATION", gettext_noop ("duration of the profiling"), &duration), - GNUNET_GETOPT_option_relative_time ('t', "timeout", "TIMEOUT", gettext_noop ("timeout for the profiling"), &timeout), - GNUNET_GETOPT_option_uint ('r', "num-requests", "COUNT", gettext_noop ("number of PeerIDs to request"), &cur_test_run.num_requests), - GNUNET_GETOPT_OPTION_END }; @@ -2995,22 +2992,24 @@ main (int argc, char *argv[]) { ret_value = 1; } - if (GNUNET_OK != ret_value) + if (0 != ret_value) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test did not run successfully!\n"); } - - ret_value = cur_test_run.eval_cb(); - if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) + else { - GNUNET_array_grow (rps_peers->cur_view, - rps_peers->cur_view_count, - 0); + ret_value = cur_test_run.eval_cb(); + if (NO_COLLECT_VIEW == cur_test_run.have_collect_view) + { + GNUNET_array_grow (rps_peers->cur_view, + rps_peers->cur_view_count, + 0); + } + GNUNET_free (rps_peers); + GNUNET_free (rps_peer_ids); + GNUNET_CONTAINER_multipeermap_destroy (peer_map); } - GNUNET_free (rps_peers); - GNUNET_free (rps_peer_ids); - GNUNET_CONTAINER_multipeermap_destroy (peer_map); return ret_value; } -- 2.25.1