aboutsummaryrefslogtreecommitdiffstats
path: root/tap-icmpstat.c
diff options
context:
space:
mode:
authorStephen Fisher <steve@stephen-fisher.com>2011-04-06 22:51:25 +0000
committerStephen Fisher <steve@stephen-fisher.com>2011-04-06 22:51:25 +0000
commit9a66ea33c42566df22f163a9bd5e87370733015e (patch)
treebe2a7b81b5204109fa9bba45162759f3b4f1e040 /tap-icmpstat.c
parent59a5ab87888f1dae83705c9b7072094f799b00dc (diff)
Fix Coverity 1181: REVERSE_INULL & improve code:
- Use g_try_malloc0() instead of g_malloc0() since the latter will fail and abort the program. Leave the NULL return check. - Don't dereference pointer before checking that it's valid. svn path=/trunk/; revision=36503
Diffstat (limited to 'tap-icmpstat.c')
-rw-r--r--tap-icmpstat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tap-icmpstat.c b/tap-icmpstat.c
index 7b586cc558..e525f01d52 100644
--- a/tap-icmpstat.c
+++ b/tap-icmpstat.c
@@ -272,12 +272,14 @@ icmpstat_init(const char *optarg, void* userdata _U_)
if (strstr(optarg, "icmp,srt,"))
filter = optarg + strlen("icmp,srt,");
- icmpstat = g_malloc0(sizeof(icmpstat_t));
- icmpstat->min_msecs = 1.0 * G_MAXUINT;
+ icmpstat = g_try_malloc0(sizeof(icmpstat_t));
if (icmpstat == NULL) {
fprintf(stderr, "tshark: g_malloc() fatal error.\n");
exit(1);
}
+
+ icmpstat->min_msecs = 1.0 * G_MAXUINT;
+
if (filter)
icmpstat->filter = g_strdup(filter);