From b2a5f15fbe44bdf46dd2c7ce4c49ab60f1d53409 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Sat, 24 Jan 2015 13:01:30 -0500 Subject: [PATCH] RTPS: Memset entire buffer Apparently some compilers do sufficient inlining optimization to notice that there's at least one caller of rtps_util_add_typecode which passes an indent_level of 0. Such compilers are *also* picky enough to complain about memset being called with a length of 0, leading to a warning which we turn into a compile error. I thought about putting in an "if indent_level > 0" but I figure memsetting the entire buffer (length >= 1) is simpler and more efficient in the common case. Change-Id: Ica21ba988eb0c1251e7b4ef2e110336d5ee32837 Reviewed-on: https://code.wireshark.org/review/6766 Reviewed-by: Evan Huus --- epan/dissectors/packet-rtps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c index 218068b53c..8298a3a0b3 100644 --- a/epan/dissectors/packet-rtps.c +++ b/epan/dissectors/packet-rtps.c @@ -1935,7 +1935,7 @@ static gint rtps_util_add_typecode(proto_tree *tree, tvbuff_t * tvb, gint offset /* Calc indent string */ indent_string = (char *)wmem_alloc(wmem_epan_scope(), (indent_level*2)+1); - memset(indent_string, ' ', indent_level*2); + memset(indent_string, ' ', (indent_level*2)+1); indent_string[indent_level*2] = '\0'; /* Gets TK ID */