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
This commit is contained in:
parent
59a5ab8788
commit
9a66ea33c4
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue