Skip to content

Commit aa64811

Browse files
committed
librlist: fix memory leak in rlist_append()
Problem: If rlist_add_rnode() fails in rlist_append(), the memory for an rnode copy is leaked. Free `copy` on failure of rlist_add_rnode().
1 parent 88dfced commit aa64811

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/common/librlist/rlist.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,10 @@ int rlist_append (struct rlist *rl, const struct rlist *rl2)
859859
struct rnode *n = zlistx_first (rl2->nodes);
860860
while (n) {
861861
struct rnode *copy = rnode_copy_avail (n);
862-
if (!copy || rlist_add_rnode (rl, copy) < 0)
862+
if (!copy || rlist_add_rnode (rl, copy) < 0) {
863+
rnode_destroy (copy);
863864
return -1;
865+
}
864866
n = zlistx_next (rl2->nodes);
865867
}
866868

0 commit comments

Comments
 (0)