aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-fix.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-01-05 10:01:04 +0000
committerGuy Harris <guy@alum.mit.edu>2005-01-05 10:01:04 +0000
commit33daa3e71583470df56175fd8890f71e37edea8c (patch)
tree7f1fcc2c6f470082bcd5bcbc7f88f8962c982372 /epan/dissectors/packet-fix.c
parentc2e6d1e6863c23e19a04df0fea02a04f2b56e91e (diff)
From Chris Maynard: don't fetch a string if we're not going to use it.
Also, move up the freeing of the tag string to immediately after we're done with it, so we don't leak it if we throw an exception getting the value. svn path=/trunk/; revision=12953
Diffstat (limited to 'epan/dissectors/packet-fix.c')
-rw-r--r--epan/dissectors/packet-fix.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/epan/dissectors/packet-fix.c b/epan/dissectors/packet-fix.c
index 7d8931d60c..aeacf739ca 100644
--- a/epan/dissectors/packet-fix.c
+++ b/epan/dissectors/packet-fix.c
@@ -12,12 +12,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -867,14 +867,12 @@ dissect_fix(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_clear(pinfo->cinfo, COL_INFO);
}
- value = tvb_get_string(tvb, value_offset, value_len);
-
if (check_col(pinfo->cinfo, COL_INFO)) {
+ value = tvb_get_string(tvb, value_offset, value_len);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s", (char *)g_datalist_get_data(&msg_types, value));
+ g_free(value);
}
- g_free(value);
-
/* In the interest of speed, if "tree" is NULL, don't do any work not
* necessary to generate protocol tree items.
*/
@@ -930,6 +928,7 @@ dissect_fix(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
tag_str = tvb_get_string(tvb, field_offset, tag_len);
tag = atoi(tag_str);
+ g_free(tag_str);
value = tvb_get_string(tvb, value_offset, value_len);
@@ -2917,7 +2916,6 @@ dissect_fix(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
field_offset = offset = ctrla_offset + 1;
ctrla_offset = tvb_find_guint8(tvb, field_offset, -1, 0x01);
- g_free(tag_str);
g_free(value);
tag_str = NULL;
}