From 5dd7371960f02a33d50faf2f7202792c1da9a042 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Tue, 14 Aug 2012 17:58:41 +0000 Subject: more ephemeral memory cleanup svn path=/trunk/; revision=44496 --- epan/dissectors/packet-ber.c | 27 +++++++++++++-------------- epan/dissectors/packet-fw1.c | 11 +++-------- epan/dissectors/packet-http.c | 11 ++--------- epan/dissectors/packet-ieee80211.c | 6 ++---- epan/dissectors/packet-mq.c | 9 ++++----- epan/dissectors/packet-multipart.c | 7 +------ epan/dissectors/packet-nfs.c | 3 +-- epan/dissectors/packet-quakeworld.c | 7 +------ epan/dissectors/packet-rlc.c | 3 +-- epan/dissectors/packet-ssl.c | 4 +--- epan/dissectors/packet-uaudp.c | 2 +- 11 files changed, 30 insertions(+), 60 deletions(-) diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index 55fcf2beff..179a513ff4 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -4266,7 +4266,7 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t } if (len < 10 || len > 19) { - error_str = g_strdup_printf("BER Error: UTCTime invalid length: %u", len); + error_str = ep_strdup_printf("BER Error: UTCTime invalid length: %u", len); instr = tvb_get_ephemeral_string(tvb, offset, len > 19 ? 19 : len); goto malformed; } @@ -4276,8 +4276,8 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t /* YYMMDDhhmm */ for(i=0;i<10;i++) { if(instr[i] < '0' || instr[i] > '9') { - error_str = g_strdup("BER Error: malformed UTCTime encoding, " - "first 10 octets have to contain YYMMDDhhmm in digits"); + error_str = "BER Error: malformed UTCTime encoding, " + "first 10 octets have to contain YYMMDDhhmm in digits"; goto malformed; } } @@ -4293,9 +4293,9 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t g_snprintf(outstrptr, 4, ":%.2s", instr+10); outstrptr+=3; } else { - error_str = g_strdup("BER Error: malformed UTCTime encoding, " + error_str = "BER Error: malformed UTCTime encoding, " "if 11th octet is a digit for seconds, " - "the 12th octet has to be a digit, too"); + "the 12th octet has to be a digit, too"; goto malformed; } } @@ -4305,8 +4305,8 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t switch (instr[i]) { case 'Z': if(len!=i+1) { - error_str = g_strdup("BER Error: malformed UTCTime encoding, " - "there must be no further octets after \'Z\'"); + error_str = "BER Error: malformed UTCTime encoding, " + "there must be no further octets after \'Z\'"; goto malformed; } g_snprintf(outstrptr, 7, " (UTC)"); @@ -4315,14 +4315,14 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t case '-': case '+': if(len!=i+5) { - error_str = g_strdup("BER Error: malformed UTCTime encoding, " - "4 digits must follow on \'+\' resp. \'-\'"); + error_str = "BER Error: malformed UTCTime encoding, " + "4 digits must follow on \'+\' resp. \'-\'"; goto malformed; } for(n=i+1;n '9') { - error_str = g_strdup("BER Error: malformed UTCTime encoding, " - "4 digits must follow on \'+\' resp. \'-\'"); + error_str = "BER Error: malformed UTCTime encoding, " + "4 digits must follow on \'+\' resp. \'-\'"; goto malformed; } } @@ -4330,7 +4330,7 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t i+=5; break; default: - error_str = g_strdup_printf("BER Error: malformed UTCTime encoding, " + error_str = ep_strdup_printf("BER Error: malformed UTCTime encoding, " "unexpected character in %dth octet, " "must be \'Z\', \'+\' or \'-\'", i+1); goto malformed; @@ -4338,7 +4338,7 @@ dissect_ber_UTCTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, t } if(len!=i) { - error_str = g_strdup_printf("BER Error: malformed UTCTime encoding, " + error_str = ep_strdup_printf("BER Error: malformed UTCTime encoding, " "%d unexpected character%s after %dth octet", len-i, (len==i-1?"s":""), i); goto malformed; @@ -4359,7 +4359,6 @@ malformed: cause = proto_tree_add_string_format(error_tree, hf_ber_error, tvb, offset, len, "invalid_utctime", "%s", error_str); expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "BER Error: malformed UTCTime encoding"); - g_free (error_str); return offset+len; } diff --git a/epan/dissectors/packet-fw1.c b/epan/dissectors/packet-fw1.c index 4d9d180a5d..022f280d8b 100644 --- a/epan/dissectors/packet-fw1.c +++ b/epan/dissectors/packet-fw1.c @@ -114,17 +114,12 @@ static gint ett_fw1 = -1; #define ETH_HEADER_SIZE 14 #define MAX_INTERFACES 20 -static char *p_interfaces[MAX_INTERFACES]; +static gchar *p_interfaces[MAX_INTERFACES]; static int interface_anzahl=0; static void fw1_init(void) { - int i; - - for (i=0; ihttp_host && stat_info->request_uri) { proto_item *e_ti; - gchar* hostname = g_strstrip(g_strdup(stat_info->http_host)); - size_t size = strlen("http://") + strlen(hostname) - + strlen(stat_info->request_uri) + 1; - char *uri = ep_alloc(size); - - g_snprintf(uri, (gulong)size, "%s://%s%s", + gchar *uri = ep_strdup_printf("%s://%s%s", "http", /* XXX, https? */ - hostname, stat_info->request_uri); - - g_free(hostname); + g_strstrip(ep_strdup(stat_info->http_host)), stat_info->request_uri); e_ti = proto_tree_add_string(http_tree, hf_http_request_full_uri, tvb, 0, diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 8ba919292e..18c0052f3c 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -16721,8 +16721,7 @@ try_decrypt(tvbuff_t *tvb, guint offset, guint len, guint8 *algorithm, guint32 * /* decrypt successful, let's set up a new data tvb. */ decr_tvb = tvb_new_child_real_data(tvb, tmp, len, len); tvb_set_free_cb(decr_tvb, g_free); - } else - g_free(tmp); + } return decr_tvb; } @@ -16740,7 +16739,7 @@ void set_airpdcap_keys(void) GByteArray *bytes = NULL; gboolean res; - keys=(PAIRPDCAP_KEYS_COLLECTION)g_malloc(sizeof(AIRPDCAP_KEYS_COLLECTION)); + keys=(PAIRPDCAP_KEYS_COLLECTION)se_alloc(sizeof(AIRPDCAP_KEYS_COLLECTION)); keys->nKeys = 0; for(i = 0; (uat_wep_key_records != NULL) && (i < num_wepkeys_uat) && (i < MAX_ENCRYPTION_KEYS); i++) @@ -16807,7 +16806,6 @@ void set_airpdcap_keys(void) /* Now set the keys */ AirPDcapSetKeys(&airpdcap_ctx,keys->Keys,keys->nKeys); - g_free(keys); if (bytes) g_byte_array_free(bytes, TRUE); diff --git a/epan/dissectors/packet-mq.c b/epan/dissectors/packet-mq.c index d9a03fc76c..d7369c5d26 100644 --- a/epan/dissectors/packet-mq.c +++ b/epan/dissectors/packet-mq.c @@ -2245,11 +2245,10 @@ dissect_mq_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8* sFormat = NULL; sFormat = tvb_get_ephemeral_string_enc(tvb, tMsgProps.iOffsetFormat, 8, string_rep); - if (strip_trailing_blanks(sFormat, 8) == 0) sFormat = (guint8*)g_strdup("MQNONE"); - if (check_col(pinfo->cinfo, COL_INFO)) - { - col_append_fstr(pinfo->cinfo, COL_INFO, " Fmt=%s", sFormat); - } + if (strip_trailing_blanks(sFormat, 8) == 0) + sFormat = (guint8*)ep_strdup("MQNONE"); + + col_append_fstr(pinfo->cinfo, COL_INFO, " Fmt=%s", sFormat); if (tree) { proto_item *hidden_item; diff --git a/epan/dissectors/packet-multipart.c b/epan/dissectors/packet-multipart.c index 5dfee10abc..91261663eb 100644 --- a/epan/dissectors/packet-multipart.c +++ b/epan/dissectors/packet-multipart.c @@ -167,8 +167,6 @@ static gint is_known_multipart_header(const char *header_str, guint len); static gint index_of_char(const char *str, const char c); -static char * -unfold_and_compact_mime_header(const char *lines, gint *first_colon_offset); /* Return a tvb that contains the binary representation of a base64 @@ -209,7 +207,7 @@ unfold_and_compact_mime_header(const char *lines, gint *first_colon_offset) if (! lines) return NULL; c = *p; - ret = g_malloc(strlen(lines) + 1); + ret = ep_alloc(strlen(lines) + 1); q = ret; while (c) { @@ -414,7 +412,6 @@ get_multipart_info(packet_info *pinfo) start = find_parameter(parameters, "boundary=", &len); if(!start) { - g_free(parameters); return NULL; } @@ -425,7 +422,6 @@ get_multipart_info(packet_info *pinfo) m_info->type = type; m_info->boundary = g_strndup(start, len); m_info->boundary_length = len; - g_free(parameters); return m_info; } @@ -709,7 +705,6 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb, const guint8 *boundary, } } } - g_free(header_str); offset = next_offset; } diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index a12ba6412f..13fc917661 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -9333,9 +9333,8 @@ dissect_nfs_argop4(tvbuff_t *tvb, int offset, packet_info *pinfo, break; case NFS4_OP_RENEW: - clientid_array = tvb_get_string(tvb, offset, 8); + clientid_array = tvb_get_ephemeral_string(tvb, offset, 8); clientid_hash = crc16_ccitt(clientid_array, 8); - g_free(clientid_array); offset = dissect_rpc_uint64(tvb, newftree, hf_nfs_clientid4, offset); g_string_append_printf (op_summary[ops_counter].optext, " CID: 0x%04x", clientid_hash); diff --git a/epan/dissectors/packet-quakeworld.c b/epan/dissectors/packet-quakeworld.c index 0e2ece17af..86f581fa54 100644 --- a/epan/dissectors/packet-quakeworld.c +++ b/epan/dissectors/packet-quakeworld.c @@ -201,13 +201,8 @@ Cmd_Argv_length(int arg) static void Cmd_TokenizeString(char* text) { - int i; int start; - /* clear the args from the last string */ - for (i=0 ; i 0 ? size / 2 : 0); + out = (unsigned char*) ep_alloc(size > 0 ? size / 2 : 0); for (i = 0; i < size; i+=2) { @@ -2093,8 +2093,6 @@ dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo, /* psk*/ memcpy(&pre_master_secret.data[psk_len + 4], ssl->psk, psk_len); - g_free(out); - ssl->pre_master_secret.data = pre_master_secret.data; ssl->pre_master_secret.data_len = pre_master_len; /*ssl_debug_printf("pre master secret",&ssl->pre_master_secret);*/ diff --git a/epan/dissectors/packet-uaudp.c b/epan/dissectors/packet-uaudp.c index ec44bf7593..ef7a5b1c35 100644 --- a/epan/dissectors/packet-uaudp.c +++ b/epan/dissectors/packet-uaudp.c @@ -666,7 +666,7 @@ void proto_reg_handoff_uaudp(void) else { use_sys_ip = FALSE; - pref_sys_ip_s = g_strdup(""); + pref_sys_ip_s = ""; } } -- cgit v1.2.3