aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-x11.c
diff options
context:
space:
mode:
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2005-08-14 05:37:12 +0000
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2005-08-14 05:37:12 +0000
commit2d511ef048ed41379e5c4cddb8c8fc9054da38bb (patch)
tree59f6bd2d0981e67ed7f2a0c09b1ae30ab8e50e30 /epan/dissectors/packet-x11.c
parent2f0dba3056fddebb3b549704f1ca228c4c5ad262 (diff)
ememify packet-x11
plug a memleak for ...].strptr that is alloced by g_malloc() but never released. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15351 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-x11.c')
-rw-r--r--epan/dissectors/packet-x11.c49
1 files changed, 5 insertions, 44 deletions
diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c
index f8f8365558..7aaa1dd04f 100644
--- a/epan/dissectors/packet-x11.c
+++ b/epan/dissectors/packet-x11.c
@@ -2005,29 +2005,16 @@ static void listOfString8(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
ti = proto_tree_add_item(t, hf, tvb, *offsetp, scanning_offset - *offsetp, little_endian);
tt = proto_item_add_subtree(ti, ett_x11_list_of_string8);
- /*
- * In case we throw an exception, clean up whatever stuff we've
- * allocated (if any).
- */
- CLEANUP_PUSH(g_free, s);
-
while(length--) {
unsigned l = VALUE8(tvb, *offsetp);
if (allocated < (l + 1)) {
- /* g_realloc doesn't work ??? */
- g_free(s);
- s = g_malloc(l + 1);
+ s = ep_alloc(l + 1);
allocated = l + 1;
}
stringCopy(s, tvb_get_ptr(tvb, *offsetp + 1, l), l); /* Nothing better for now. We need a better string handling API. */
proto_tree_add_string_format(tt, hf_item, tvb, *offsetp, l + 1, s, "\"%s\"", s);
*offsetp += l + 1;
}
-
- /*
- * Call the cleanup handler to free the string and pop the handler.
- */
- CLEANUP_CALL_AND_POP;
}
#define STRING16_MAX_DISPLAYED_LENGTH 150
@@ -2062,8 +2049,7 @@ static void string16_with_buffer_preallocated(tvbuff_t *tvb, proto_tree *t,
l = STRING16_MAX_DISPLAYED_LENGTH;
}
if (*sLength < (int) l + 3) {
- g_free(*s);
- *s = g_malloc(l + 3);
+ *s = ep_alloc(l + 3);
*sLength = l + 3;
}
dp = *s;
@@ -2114,12 +2100,6 @@ static void listOfTextItem(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
ti = proto_tree_add_item(t, hf, tvb, *offsetp, scanning_offset - *offsetp, little_endian);
tt = proto_item_add_subtree(ti, ett_x11_list_of_text_item);
- /*
- * In case we throw an exception, clean up whatever stuff we've
- * allocated (if any).
- */
- CLEANUP_PUSH(g_free, s);
-
while(n--) {
unsigned l = VALUE8(tvb, *offsetp);
if (l == 255) { /* Item is a font */
@@ -2132,9 +2112,7 @@ static void listOfTextItem(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
gint8 delta = VALUE8(tvb, *offsetp + 1);
if (sizeIs16) l += l;
if ((unsigned) allocated < l + 1) {
- /* g_realloc doesn't work ??? */
- g_free(s);
- s = g_malloc(l + 1);
+ s = ep_alloc(l + 1);
allocated = l + 1;
}
stringCopy(s, tvb_get_ptr(tvb, *offsetp + 2, l), l);
@@ -2155,11 +2133,6 @@ static void listOfTextItem(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
*offsetp += l + 2;
}
}
-
- /*
- * Call the cleanup handler to free the string and pop the handler.
- */
- CLEANUP_CALL_AND_POP;
}
static guint32 field8(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
@@ -2417,10 +2390,9 @@ static void string8(tvbuff_t *tvb, int *offsetp, proto_tree *t,
char *s;
p = tvb_get_ptr(tvb, *offsetp, length);
- s = g_malloc(length + 1);
+ s = ep_alloc(length + 1);
stringCopy(s, p, length);
proto_tree_add_string(t, hf, tvb, *offsetp, length, s);
- g_free(s);
*offsetp += length;
}
@@ -2432,21 +2404,10 @@ static void string16(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
char *s = NULL;
unsigned l = 0;
- /*
- * In case we throw an exception, clean up whatever stuff we've
- * allocated (if any).
- */
- CLEANUP_PUSH(g_free, s);
-
length += length;
string16_with_buffer_preallocated(tvb, t, hf, hf_bytes, *offsetp, length,
&s, &l, little_endian);
- /*
- * Call the cleanup handler to free the string and pop the handler.
- */
- CLEANUP_CALL_AND_POP;
-
*offsetp += length;
}
@@ -3005,7 +2966,7 @@ static void dissect_x11_request(tvbuff_t *tvb, packet_info *pinfo,
/* necessary processing even if tree == NULL */
v16 = VALUE16(tvb, 4);
- name = g_malloc(v16 + 1);
+ name = se_alloc(v16 + 1);
stringCopy(name, tvb_get_ptr(tvb, 8, v16), v16);
/* store string of extension, opcode will be set at reply */