From a38478c97d421afb0ba6271dbd8695685cd35e9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 23 Aug 2018 21:51:25 -0400 Subject: [PATCH] Fix: size of concrete class used in memcpy of base class MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit session rotation condition and evaluation objects' base class is initialized from a template to set the various method's function pointers to the functions implementing their interface. The memcpy() erroneously uses the "derived" class' size through sizeof(*obj) rather than the size of the base class through sizeof(obj->parent). Signed-off-by: Jérémie Galarneau --- src/common/session-rotation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/session-rotation.c b/src/common/session-rotation.c index be48a998a..0bd91e74f 100644 --- a/src/common/session-rotation.c +++ b/src/common/session-rotation.c @@ -194,7 +194,7 @@ struct lttng_condition *lttng_condition_session_rotation_create( } memcpy(&condition->parent, &rotation_condition_template, - sizeof(*condition)); + sizeof(condition->parent)); lttng_condition_init(&condition->parent, type); return &condition->parent; } @@ -341,7 +341,7 @@ struct lttng_evaluation *lttng_evaluation_session_rotation_create( } memcpy(&evaluation->parent, &rotation_evaluation_template, - sizeof(*evaluation)); + sizeof(evaluation->parent)); lttng_evaluation_init(&evaluation->parent, type); evaluation->id = id; evaluation->location = location; -- 2.34.1