}
ast_debug(2, "Subscription to leaf resource %s resulted in success. Adding to parent %s\n",
resource, parent->resource);
- AST_VECTOR_APPEND(&parent->children, current);
+ if (AST_VECTOR_APPEND(&parent->children, current)) {
+ tree_node_destroy(current);
+ }
} else {
ast_debug(2, "Subscription to leaf resource %s resulted in error response %d\n",
resource, resp);
build_node_children(endpoint, handler, child_list, current, visited);
if (AST_VECTOR_SIZE(¤t->children) > 0) {
ast_debug(1, "List %s had no successful children.\n", resource);
- AST_VECTOR_APPEND(&parent->children, current);
+ if (AST_VECTOR_APPEND(&parent->children, current)) {
+ tree_node_destroy(current);
+ }
} else {
ast_debug(2, "List %s had successful children. Adding to parent %s\n",
resource, parent->resource);
if (AST_VECTOR_APPEND(&sub->children, child)) {
ast_debug(1, "Child subscription to resource %s could not be appended\n",
child_node->resource);
+ destroy_subscription(child);
+ /* Have to release tree here too because a ref was added
+ * to child that destroy_subscription() doesn't release. */
+ ao2_cleanup(tree);
}
}
bp->part->body = body;
pj_list_insert_before(&bp->part->hdr, bp->cid);
- AST_VECTOR_APPEND(parts, bp);
+ if (AST_VECTOR_APPEND(parts, bp)) {
+ ast_free(bp);
+ }
}
/*!
/* This can happen if issuing partial state and no children of the list have changed state */
if (AST_VECTOR_SIZE(&body_parts) == 0) {
+ free_body_parts(&body_parts);
return NULL;
}
rlmi_part = build_rlmi_body(pool, sub, &body_parts, use_full_state);
if (!rlmi_part) {
+ free_body_parts(&body_parts);
return NULL;
}
pjsip_multipart_add_part(pool, multipart, rlmi_part);
ast_log(LOG_WARNING, "Ignoring duplicated list item '%s'\n", item);
continue;
}
- if (AST_VECTOR_APPEND(&list->items, ast_strdup(item))) {
+
+ item = ast_strdup(item);
+ if (!item || AST_VECTOR_APPEND(&list->items, item)) {
+ ast_free(item);
return -1;
}
}
ast_copy_string(list->event, event, sizeof(list->event));
for (i = 0; i < num_resources; ++i) {
- if (AST_VECTOR_APPEND(&list->items, ast_strdup(resources[i]))) {
+ char *resource = ast_strdup(resources[i]);
+
+ if (!resource || AST_VECTOR_APPEND(&list->items, resource)) {
+ ast_free(resource);
return -1;
}
}