From: Jérémie Galarneau Date: Fri, 24 Aug 2018 01:51:25 +0000 (-0400) Subject: Fix: size of concrete class used in memcpy of base class X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=a38478c97d421afb0ba6271dbd8695685cd35e9f;hp=88a5c0a9ce2333f12a1bd5d6b0ea527b86cde819 Fix: size of concrete class used in memcpy of base class 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 --- 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;