aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-08-21 00:35:38 -0700
committerGuy Harris <guy@alum.mit.edu>2014-08-21 07:39:58 +0000
commit66318ad5eb8235e73e66acee372df7c47cfea8bd (patch)
treebb56fe28a2937bb26700c1b099fb2152aec387fd /epan/tvbuff.c
parentbed29af46db06f4bce00d8a4dab26317d4563dd3 (diff)
Don't assert out on tvb_memcpy() with a null data pointer if the length is 0.
If the length is 0, there's nothing to copy, so it doesn't matter if there's no data to copy from. This fixes problems caused by allocating a zero-length buffer and using that as the data for a tvbuff; the allocation returns null, so the data pointer is null. Change-Id: I8037ae4b96d30e90a716852bb7e22d3980444f83 Reviewed-on: https://code.wireshark.org/review/3761 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index f087480509..33e86a3289 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -795,9 +795,17 @@ tvb_memcpy(tvbuff_t *tvb, void *target, const gint offset, size_t length)
if (tvb->ops->tvb_memcpy)
return tvb->ops->tvb_memcpy(tvb, target, abs_offset, abs_length);
- /* XXX, fallback to slower method */
-
- DISSECTOR_ASSERT_NOT_REACHED();
+ /*
+ * If the length is 0, there's nothing to do.
+ * (tvb->real_data could be null if it's allocated with
+ * a size of length.)
+ */
+ if (length != 0) {
+ /*
+ * XXX, fallback to slower method
+ */
+ DISSECTOR_ASSERT_NOT_REACHED();
+ }
return NULL;
}