From 17f72a0b2273e8c45296711d2454997e74e2734c Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Sun, 23 Jul 2017 23:11:42 +0200 Subject: [PATCH] randpkt: choose a random type if the empty string has been selected as type. Fixes a bug when calling randpktdump without the dialog. Reproducer: Open wireshark Double click on randpktdump Stop the capture No packets have been generated. Change-Id: I43d1d3c02afbb44f88620a696a7d25aa4e45889a Reviewed-on: https://code.wireshark.org/review/22775 Petri-Dish: Dario Lombardo Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- randpkt_core/randpkt_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c index 20900c6279..f35077b7b4 100644 --- a/randpkt_core/randpkt_core.c +++ b/randpkt_core/randpkt_core.c @@ -698,8 +698,8 @@ int randpkt_parse_type(char *string) int num_entries = array_length(examples); int i; - /* Called with NULL, choose a random packet */ - if (!string) { + /* If called with NULL, or empty string, choose a random packet */ + if (!string || !g_strcmp0(string, "")) { return examples[g_random_int_range(0, num_entries)].produceable_type; } @@ -710,7 +710,7 @@ int randpkt_parse_type(char *string) } /* Complain */ - fprintf(stderr, "randpkt: Type %s not known.\n", string); + g_error("randpkt: Type %s not known.\n", string); return -1; }