diff options
author | Laurent Deniel <laurent.deniel@free.fr> | 2003-04-27 20:57:58 +0000 |
---|---|---|
committer | Laurent Deniel <laurent.deniel@free.fr> | 2003-04-27 20:57:58 +0000 |
commit | 4e9e69953627fb04006b837cafb321f4ce2903c3 (patch) | |
tree | 00c602dc312171ce7950b4adea022ab46ec65885 | |
parent | 5f98b6206f7a671a30bfa095ea02c7f8cddfe7cc (diff) | |
download | wireshark-4e9e69953627fb04006b837cafb321f4ce2903c3.tar.gz wireshark-4e9e69953627fb04006b837cafb321f4ce2903c3.tar.bz2 wireshark-4e9e69953627fb04006b837cafb321f4ce2903c3.zip |
Replace some unchecked malloc calls by g_malloc.
svn path=/trunk/; revision=7584
-rw-r--r-- | packet-icmpv6.c | 4 | ||||
-rw-r--r-- | packet-ieee80211.c | 10 | ||||
-rw-r--r-- | packet-rsync.c | 6 | ||||
-rw-r--r-- | packet-rtcp.c | 10 | ||||
-rw-r--r-- | packet-snmp.c | 12 | ||||
-rw-r--r-- | packet-telnet.c | 4 |
6 files changed, 22 insertions, 24 deletions
diff --git a/packet-icmpv6.c b/packet-icmpv6.c index 9225b82e8f..33a1acea7a 100644 --- a/packet-icmpv6.c +++ b/packet-icmpv6.c @@ -1,7 +1,7 @@ /* packet-icmpv6.c * Routines for ICMPv6 packet disassembly * - * $Id: packet-icmpv6.c,v 1.70 2003/02/04 20:16:57 guy Exp $ + * $Id: packet-icmpv6.c,v 1.71 2003/04/27 20:57:58 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -216,7 +216,7 @@ again: char *t; int len, i, p; len = (opt->nd_opt_len << 3) - sizeof(*opt); - t = (char *)malloc(len * 3); + t = g_malloc(len * 3); memset(t, 0, len * 3); p = offset + sizeof(*opt); for (i = 0; i < len; i++) { diff --git a/packet-ieee80211.c b/packet-ieee80211.c index 4984dbe58b..9e3adc0f32 100644 --- a/packet-ieee80211.c +++ b/packet-ieee80211.c @@ -3,7 +3,7 @@ * Copyright 2000, Axis Communications AB * Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com * - * $Id: packet-ieee80211.c,v 1.85 2003/04/20 11:36:13 guy Exp $ + * $Id: packet-ieee80211.c,v 1.86 2003/04/27 20:57:58 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -2642,8 +2642,6 @@ static int wep_decrypt(guint8 *buf, guint32 len, int key_override) { return 0; } -/* XXX need to verify these malloc()s succeed */ - static void init_wepkeys(void) { char *tmp, *tmp2; guint8 *tmp3; @@ -2669,8 +2667,8 @@ static void init_wepkeys(void) { if (wep_keylens != NULL) return; - wep_keys = malloc(num_wepkeys * sizeof(guint8*)); - wep_keylens = malloc(num_wepkeys * sizeof(int)); + wep_keys = g_malloc(num_wepkeys * sizeof(guint8*)); + wep_keylens = g_malloc(num_wepkeys * sizeof(int)); for (i = 0 ; i < num_wepkeys; i++) { wep_keys[i] = NULL; @@ -2693,7 +2691,7 @@ static void init_wepkeys(void) { #endif #endif - wep_keys[i] = malloc(32 * sizeof(guint8)); + wep_keys[i] = g_malloc(32 * sizeof(guint8)); memset(wep_keys[i], 0, 32 * sizeof(guint8)); tmp3 = wep_keys[i]; while ((tmp != NULL) && (*tmp != 0)) { diff --git a/packet-rsync.c b/packet-rsync.c index 69bd4f07da..9c3ae1e315 100644 --- a/packet-rsync.c +++ b/packet-rsync.c @@ -3,7 +3,7 @@ * [ very rough, but mininally functional ] * Copyright 2003, Brad Hards <bradh@frogmouth.net> * - * $Id: packet-rsync.c,v 1.3 2003/03/01 14:12:38 deniel Exp $ + * $Id: packet-rsync.c,v 1.4 2003/04/27 20:57:58 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -117,7 +117,7 @@ dissect_rsync_encap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, conversation_data = conversation_get_proto_data(conversation, proto_rsync); if (conversation_data == NULL) { - conversation_data = malloc(sizeof(struct rsync_conversation_data)); + conversation_data = g_malloc(sizeof(struct rsync_conversation_data)); conversation_data->state = RSYNC_INIT; conversation_add_proto_data(conversation, proto_rsync, conversation_data); } @@ -131,7 +131,7 @@ dissect_rsync_encap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, frame_data = p_get_proto_data(pinfo->fd, proto_rsync); if (!frame_data) { /* then we haven't seen this frame before */ - frame_data = malloc(sizeof(struct rsync_frame_data)); + frame_data = g_malloc(sizeof(struct rsync_frame_data)); frame_data->state = conversation_data->state; p_add_proto_data(pinfo->fd, proto_rsync, frame_data); } diff --git a/packet-rtcp.c b/packet-rtcp.c index 5f038b0d75..d9918d8933 100644 --- a/packet-rtcp.c +++ b/packet-rtcp.c @@ -1,6 +1,6 @@ /* packet-rtcp.c * - * $Id: packet-rtcp.c,v 1.35 2002/08/28 21:00:29 jmayer Exp $ + * $Id: packet-rtcp.c,v 1.36 2003/04/27 20:57:58 deniel Exp $ * * Routines for RTCP dissection * RTCP = Real-time Transport Control Protocol @@ -230,7 +230,7 @@ static void rtcp_init( void ) fake_addr.type = AT_IPv4; fake_addr.len = 4; - tmp_data = malloc( fake_addr.len ); + tmp_data = g_malloc( fake_addr.len ); for ( i = 0; i < fake_addr.len; i++) { tmp_data[i] = 0; } @@ -385,7 +385,7 @@ dissect_rtcp_bye( tvbuff_t *tvb, int offset, proto_tree *tree, proto_tree_add_item( tree, hf_rtcp_ssrc_length, tvb, offset, 1, FALSE ); offset++; - reason_text = ( char* ) malloc( reason_length + 1 ); + reason_text = g_malloc( reason_length + 1 ); for ( counter = 0; counter < reason_length; counter++ ) reason_text[ counter ] = tvb_get_guint8( tvb, offset + counter ); /* strncpy( reason_text, pd + offset, reason_length ); */ reason_text[ reason_length ] = '\0'; @@ -462,7 +462,7 @@ dissect_rtcp_sdes( tvbuff_t *tvb, int offset, proto_tree *tree, proto_tree_add_item( sdes_item_tree, hf_rtcp_ssrc_prefix_len, tvb, offset, 1, FALSE ); offset++; - prefix_string = ( char * ) malloc( prefix_len + 1 ); + prefix_string = g_malloc( prefix_len + 1 ); for ( counter = 0; counter < prefix_len; counter++ ) prefix_string[ counter ] = tvb_get_guint8( tvb, offset + counter ); @@ -472,7 +472,7 @@ dissect_rtcp_sdes( tvbuff_t *tvb, int offset, proto_tree *tree, free( prefix_string ); offset += prefix_len; } - prefix_string = ( char * ) malloc( item_len + 1 ); + prefix_string = g_malloc( item_len + 1 ); for ( counter = 0; counter < item_len; counter++ ) prefix_string[ counter ] = tvb_get_guint8( tvb, offset + counter ); diff --git a/packet-snmp.c b/packet-snmp.c index 110bd6cc5b..5fd77f7084 100644 --- a/packet-snmp.c +++ b/packet-snmp.c @@ -10,7 +10,7 @@ * * See RFCs 2570-2576 for SNMPv3 * - * $Id: packet-snmp.c,v 1.107 2003/04/19 09:45:25 guy Exp $ + * $Id: packet-snmp.c,v 1.108 2003/04/27 20:57:58 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -540,10 +540,10 @@ format_oid(subid_t *oid, guint oid_length) * Get the decoded form of the OID, and add its length to the * length of the result string. * - * XXX - check for "malloc" and "sprint_realloc_objid()" failure. + * XXX - check for "sprint_realloc_objid()" failure. */ oid_string_len = 256; - oid_string = malloc(oid_string_len); + oid_string = g_malloc(oid_string_len); *oid_string = '\0'; oid_out_len = 0; sprint_realloc_objid(&oid_string, &oid_string_len, &oid_out_len, 1, @@ -582,7 +582,7 @@ check_var_length(guint vb_length, guint required_length) /* Enough room for the largest "Length is XXX, should be XXX" message - 10 digits for each XXX. */ - buf = malloc(sizeof badlen_fmt + 10 + 10); + buf = g_malloc(sizeof badlen_fmt + 10 + 10); sprintf(buf, badlen_fmt, vb_length, required_length); return buf; } @@ -669,10 +669,10 @@ format_var(struct variable_list *variable, subid_t *variable_oid, variable->val_len = val_len; /* - * XXX - check for "malloc" and "sprint_realloc_objid()" failure. + * XXX - check for "sprint_realloc_objid()" failure. */ buf_len = 256; - buf = malloc(buf_len); + buf = g_malloc(buf_len); *buf = '\0'; out_len = 0; sprint_realloc_value(&buf, &buf_len, &out_len, 1, variable_oid, diff --git a/packet-telnet.c b/packet-telnet.c index 0e044cbca5..e0488772f4 100644 --- a/packet-telnet.c +++ b/packet-telnet.c @@ -2,7 +2,7 @@ * Routines for Telnet packet dissection; see RFC 854 and RFC 855 * Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com> * - * $Id: packet-telnet.c,v 1.38 2003/04/22 20:35:48 guy Exp $ + * $Id: packet-telnet.c,v 1.39 2003/04/27 20:57:58 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -406,7 +406,7 @@ dissect_comport_subopt(const char *optname, tvbuff_t *tvb, int offset, int len, if (len == 0) { proto_tree_add_text(tree, tvb, offset, 1, "%s Requests Signature",source); } else { - guint8 *sig = (char *)malloc(len + 4); + guint8 *sig = g_malloc(len + 4); gint siglen = tvb_get_nstringz0(tvb, offset+1, len, sig); proto_tree_add_text(tree, tvb, offset, 1 + siglen, "%s Signature: %s",source, sig); free(sig); |