Fix bytes_repr_len() to correctly handle a zero-length FT_BYTES field
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 7 Nov 2006 20:30:34 +0000 (20:30 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 7 Nov 2006 20:30:34 +0000 (20:30 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@19863 f5534014-38df-0310-8fa8-9805f1628bb7

epan/ftypes/ftype-bytes.c

index 095eb6767286b6b3b4145d01fe8d2cb023f78713..88c46b2e311c7c009ee642d01bdf4f93d4ac15ed 100644 (file)
@@ -70,9 +70,15 @@ bytes_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
 static int
 bytes_repr_len(fvalue_t *fv, ftrepr_t rtype _U_)
 {
-       /* 3 bytes for each byte of the byte "NN:" minus 1 byte
-        * as there's no trailing ":". */
-       return fv->value.bytes->len * 3 - 1;
+       if (fv->value.bytes->len == 0) {
+               /* Empty array of bytes, so the representation
+                * is an empty string. */
+               return 0;
+       } else {
+               /* 3 bytes for each byte of the byte "NN:" minus 1 byte
+                * as there's no trailing ":". */
+               return fv->value.bytes->len * 3 - 1;
+       }
 }
 
 static int