X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fcomponent.c;h=9ed599448880b647d4d122fd9c50c2d8bb297cde;hb=bd14d76835630e092320c8a04300088242dcdc99;hp=c541985b3326b52f374829f877ba162f3aa835db;hpb=4a6b963eb0e4e9545deacfc74d81d3b9f96f060f;p=babeltrace.git diff --git a/lib/graph/component.c b/lib/graph/component.c index c541985b..9ed59944 100644 --- a/lib/graph/component.c +++ b/lib/graph/component.c @@ -78,6 +78,16 @@ void bt_component_destroy(struct bt_object *obj) return; } + /* + * The component's reference count is 0 if we're here. Increment + * it to avoid a double-destroy (possibly infinitely recursive). + * This could happen for example if the component's finalization + * function does bt_get() (or anything that causes bt_get() to + * be called) on itself (ref. count goes from 0 to 1), and then + * bt_put(): the reference count would go from 1 to 0 again and + * this function would be called again. + */ + obj->ref_count.count++; component = container_of(obj, struct bt_component, base); /* Call destroy listeners in reverse registration order */