From de0d26aea74f893a01a33318bcf48e9b91826de5 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 5 Mar 2002 09:18:58 +0000 Subject: Fix another problem found by the PROTOS captures - in "asn1_string_value_decode()", don't pass "g_malloc()" an argument of 0, as "g_malloc()" will return NULL in that case, and the callers of "asn1_string_value_decode()" aren't necessarily prepared for a null argument. svn path=/trunk/; revision=4876 --- asn1.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'asn1.c') diff --git a/asn1.c b/asn1.c index e7cf347832..a452de42e8 100644 --- a/asn1.c +++ b/asn1.c @@ -1,7 +1,7 @@ /* asn1.c * Routines for ASN.1 BER dissection * - * $Id: asn1.c,v 1.11 2002/03/01 02:48:10 guy Exp $ + * $Id: asn1.c,v 1.12 2002/03/05 09:18:58 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -674,10 +674,18 @@ asn1_string_value_decode ( ASN1_SCK *asn1, int enc_len, guchar **octets) * We do that by attempting to fetch the last byte (if the length * isn't 0). */ - if (enc_len != 0) + if (enc_len != 0) { tvb_get_guint8(asn1->tvb, eoc - 1); - - *octets = g_malloc (enc_len); + *octets = g_malloc (enc_len); + } else { + /* + * If the length is 0, we allocate a 1-byte buffer, as + * "g_malloc()" returns NULL if passed 0 as an argument, + * and our caller expects us to return a pointer to a + * buffer. + */ + *octets = g_malloc (1); + } ptr = *octets; while (asn1->offset < eoc) { ret = asn1_octet_decode (asn1, (guchar *)ptr++); -- cgit v1.2.3