diff options
author | sfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-06 22:51:25 +0000 |
---|---|---|
committer | sfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7> | 2011-04-06 22:51:25 +0000 |
commit | d60105b85fc2a0fb37515557480925d0bdb6523a (patch) | |
tree | be2a7b81b5204109fa9bba45162759f3b4f1e040 /tap-icmpstat.c | |
parent | 84511112c5ae14052ded0bfffba3c295dfb9d850 (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.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36503 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'tap-icmpstat.c')
-rw-r--r-- | tap-icmpstat.c | 6 |
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); |