]> granicus.if.org Git - ejabberd/commitdiff
Avoid orphan_item leak on affiliation/subscription removal (#1563)
authorChristophe Romain <christophe.romain@process-one.net>
Thu, 23 Feb 2017 15:43:22 +0000 (16:43 +0100)
committerChristophe Romain <christophe.romain@process-one.net>
Thu, 23 Feb 2017 15:43:22 +0000 (16:43 +0100)
src/node_flat.erl

index 1809915ff8dbaed0294cf28108db9f0192360997..90785842896c3d0847a28ac492b85052fc84ef19 100644 (file)
@@ -707,7 +707,13 @@ del_state(#pubsub_state{stateid = {Key, Nidx}, items = Items}) ->
        [] ->
            ok;
        _ ->
-           Orphan = #pubsub_orphan{nodeid = Nidx, items = Items},
+           Orphan = #pubsub_orphan{nodeid = Nidx, items =
+               case mnesia:read({pubsub_orphan, Nidx}) of
+                   [#pubsub_orphan{items = ItemIds}] ->
+                       lists:usort(ItemIds++Items);
+                 _ ->
+                       Items
+               end},
            mnesia:write(Orphan)
     end,
     mnesia:delete({pubsub_state, {Key, Nidx}}).