Have show_exception() take a "const char *" as its exception message,

and not free the string to which it points.  Pass to
REPORT_DISSECTOR_BUG() strings allocated with ep_strdup_printf(), so
that they're freed automatically.

svn path=/trunk/; revision=16039
This commit is contained in:
Guy Harris 2005-09-28 16:16:37 +00:00
parent e2d774be16
commit f6ef22c553
17 changed files with 22 additions and 11 deletions

View File

@ -5560,6 +5560,7 @@ def produce_code():
#include <epan/packet.h>
#include <epan/conversation.h>
#include <epan/ptvcursor.h>
#include <epan/emem.h>
#include "packet-ncp-int.h"
#include "packet-ncp-nmas.h"
#include <epan/strutil.h>

View File

@ -35,6 +35,7 @@
#include <math.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <prefs.h>
/*#define BSSGP_DEBUG*/

View File

@ -84,6 +84,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include "packet-dcerpc.h"
#include "packet-dcom.h"
#include "prefs.h"

View File

@ -32,6 +32,7 @@
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/nlpid.h>
#include "packet-osi.h"
#include "packet-osi-options.h"

View File

@ -261,7 +261,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
void
show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
unsigned long exception, char *exception_message)
unsigned long exception, const char *exception_message)
{
static const char dissector_error_nomsg[] =
"Dissector writer didn't bother saying what the error was";
@ -306,8 +306,6 @@ show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
"%s",
exception_message == NULL ?
dissector_error_nomsg : exception_message);
if (exception_message != NULL)
g_free(exception_message);
break;
default:

View File

@ -27,7 +27,7 @@
* Routine used to add an indication of an arbitrary exception to the tree.
*/
void show_exception(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
unsigned long exception, char *exception_message);
unsigned long exception, const char *exception_message);
/*
* Routine used to add an indication of a ReportedBoundsError exception

View File

@ -70,6 +70,7 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/emem.h>
#include <epan/reassemble.h>
static void dissect_gsm_sms_ud(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);

View File

@ -36,6 +36,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
/* MSDP message types. The messages are TLV (Type-Length-Value) encoded */
enum { MSDP_SA = 1,

View File

@ -32,6 +32,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/ipproto.h>
#include <epan/afn.h>
#include "packet-ipv6.h"

View File

@ -33,6 +33,7 @@
#include <glib.h>
#include <epan/prefs.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include "packet-ppp.h"
#include <epan/ppptypes.h>
#include <epan/etypes.h>

View File

@ -28,6 +28,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/strutil.h>
#include <epan/etypes.h>

View File

@ -42,6 +42,7 @@ XXX Fixme : shouldnt show [malformed frame] for long packets
#include <glib.h>
#include <ctype.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/dissectors/packet-smb.h>
#include "packet-smb-pipe.h"
#include "packet-smb-browse.h"

View File

@ -30,6 +30,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/llcsaps.h>
#include <epan/ppptypes.h>
#include <epan/sna-utils.h>

View File

@ -35,6 +35,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/addr_resolv.h>
#include <epan/ipproto.h>
#include <epan/in_cksum.h>

View File

@ -26,6 +26,7 @@
#include <ftypes-int.h>
#include <string.h>
#include <epan/emem.h>
#ifdef HAVE_LIBPCRE
#include <pcre.h>

View File

@ -2142,10 +2142,10 @@ proto_tree_add_node(proto_tree *tree, field_info *fi)
tnode = tree;
tfi = tnode->finfo;
if (tfi != NULL && (tfi->tree_type < 0 || tfi->tree_type >= num_tree_types)) {
REPORT_DISSECTOR_BUG(g_strdup_printf("\"%s\" - \"%s\" tfi->tree_type: %u invalid (%s:%u)",
REPORT_DISSECTOR_BUG(ep_strdup_printf("\"%s\" - \"%s\" tfi->tree_type: %u invalid (%s:%u)",
fi->hfinfo->name, fi->hfinfo->abbrev, tfi->tree_type, __FILE__, __LINE__));
/* XXX - is it safe to continue here? */
}
/* XXX - is it safe to continue here? */
}
DISSECTOR_ASSERT(tfi == NULL ||
(tfi->tree_type >= 0 && tfi->tree_type < num_tree_types));

View File

@ -84,8 +84,8 @@ typedef struct _protocol protocol_t;
* as the message for the exception, so that it can show up in
* the Info column and the protocol tree.
*
* That string should be allocated with g_malloc(); using
* "g_strdup_printf()" would work.
* If that string is dynamically allocated, it should be allocated with
* ep_alloc(); using ep_strdup_printf() would work.
*
* If the ETHEREAL_ABORT_ON_DISSECTOR_BUG environment variable is set,
* it will call abort(), instead, to make it easier to get a stack trace.
@ -119,14 +119,14 @@ typedef struct _protocol protocol_t;
*/
#define DISSECTOR_ASSERT_NOT_REACHED() \
(REPORT_DISSECTOR_BUG( \
g_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
__FILE__, __LINE__)))
#define __DISSECTOR_ASSERT_STRINGIFY(s) # s
#define __DISSECTOR_ASSERT(expression, file, lineno) \
(REPORT_DISSECTOR_BUG( \
g_strdup_printf("%s:%u: failed assertion \"%s\"", \
ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
/** radix for decimal values, used in header_field_info.display */