ao2_iterator: Mini-audit of the ao2_iterator loops in the new code files.
[asterisk/asterisk.git] / res / ari / resource_channels.c
index 08ef154..667ea73 100644 (file)
@@ -663,8 +663,8 @@ void ast_ari_channels_list(struct ast_variable *headers,
                return;
        }
 
-       for (i = ao2_iterator_init(snapshots, 0);
-               (obj = ao2_iterator_next(&i)); ao2_cleanup(obj)) {
+       i = ao2_iterator_init(snapshots, 0);
+       while ((obj = ao2_iterator_next(&i))) {
                RAII_VAR(struct stasis_message *, msg, obj, ao2_cleanup);
                struct ast_channel_snapshot *snapshot = stasis_message_data(msg);
                int r;
@@ -678,7 +678,6 @@ void ast_ari_channels_list(struct ast_variable *headers,
                        json, ast_channel_snapshot_to_json(snapshot, NULL));
                if (r != 0) {
                        ast_ari_response_alloc_failed(response);
-                       ao2_cleanup(obj);
                        ao2_iterator_destroy(&i);
                        return;
                }