aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-03-05 09:18:58 +0000
committerGuy Harris <guy@alum.mit.edu>2002-03-05 09:18:58 +0000
commitde0d26aea74f893a01a33318bcf48e9b91826de5 (patch)
tree6b95445d90db617c8d538b388b502684359b87fe
parentb5e9cef2bfa66c607b3282952cfb4ce11976dd18 (diff)
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
-rw-r--r--asn1.c16
1 files changed, 12 insertions, 4 deletions
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 <gerald@ethereal.com>
@@ -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++);