diff --git a/main/features_config.c b/main/features_config.c index d58886eec7..ca0ee7781f 100644 --- a/main/features_config.c +++ b/main/features_config.c @@ -1081,7 +1081,8 @@ static struct ast_datastore *get_feature_chan_ds(struct ast_channel *chan) if (!(ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL))) { /* Hasn't been created yet. Trigger creation. */ - RAII_VAR(struct features_config *, cfg, get_feature_ds(chan), ao2_cleanup); + ao2_cleanup(get_feature_ds(chan)); + ds = ast_channel_datastore_find(chan, &feature_ds_info, NULL); } diff --git a/main/rtp_engine.c b/main/rtp_engine.c index 48372303af..e47ab833fd 100644 --- a/main/rtp_engine.c +++ b/main/rtp_engine.c @@ -1915,28 +1915,22 @@ void ast_rtp_publish_rtcp_message(struct ast_rtp_instance *rtp, struct ast_rtp_rtcp_report *report, struct ast_json *blob) { - RAII_VAR(struct rtcp_message_payload *, payload, - ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor), ao2_cleanup); - RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup); + RAII_VAR(struct rtcp_message_payload *, payload, NULL, ao2_cleanup); RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); + payload = ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor); if (!payload || !report) { return; } if (!ast_strlen_zero(rtp->channel_uniqueid)) { - snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid); - if (snapshot) { - ao2_ref(snapshot, +1); - } + payload->snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid); } - if (blob) { + payload->blob = blob; ast_json_ref(blob); } - ao2_ref(report, 1); - payload->snapshot = snapshot; - payload->blob = blob; + ao2_ref(report, +1); payload->report = report; message = stasis_message_create(message_type, payload); diff --git a/main/stasis_channels.c b/main/stasis_channels.c index c75d174925..eefb7a9f8f 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -172,8 +172,8 @@ static void channel_snapshot_dtor(void *obj) struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *chan) { - RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup); - RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup); + struct ast_channel_snapshot *snapshot; + struct ast_bridge *bridge; char nativeformats[256]; struct ast_str *write_transpath = ast_str_alloca(256); struct ast_str *read_transpath = ast_str_alloca(256); @@ -187,6 +187,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha snapshot = ao2_alloc(sizeof(*snapshot), channel_snapshot_dtor); if (!snapshot || ast_string_field_init(snapshot, 1024)) { + ao2_cleanup(snapshot); return NULL; } @@ -231,6 +232,7 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha if ((bridge = ast_channel_get_bridge(chan))) { ast_string_field_set(snapshot, bridgeid, bridge->uniqueid); + ao2_cleanup(bridge); } ast_string_field_set(snapshot, nativeformats, ast_getformatname_multiple(nativeformats, sizeof(nativeformats), @@ -267,7 +269,6 @@ struct ast_channel_snapshot *ast_channel_snapshot_create(struct ast_channel *cha snapshot->channel_vars = ast_channel_get_vars(chan); snapshot->tech_properties = ast_channel_tech(chan)->properties; - ao2_ref(snapshot, +1); return snapshot; } diff --git a/res/res_parking.c b/res/res_parking.c index c36d558b6e..c60fdd61ae 100644 --- a/res/res_parking.c +++ b/res/res_parking.c @@ -890,11 +890,10 @@ static void generate_or_link_lots_to_configs(void) struct parking_lot_cfg *lot_cfg; struct ao2_iterator iter; - for (iter = ao2_iterator_init(cfg->parking_lots, 0); (lot_cfg = ao2_iterator_next(&iter)); ao2_ref(lot_cfg, -1)) { - RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup); - lot = parking_lot_build_or_update(lot_cfg, 0); + iter = ao2_iterator_init(cfg->parking_lots, 0); + for (; (lot_cfg = ao2_iterator_next(&iter)); ao2_ref(lot_cfg, -1)) { + ao2_cleanup(parking_lot_build_or_update(lot_cfg, 0)); } - ao2_iterator_destroy(&iter); }