roster.go
changeset 54 b345e0473430
parent 52 9b664fde0ec3
child 55 ce9f9f7108c8
--- a/roster.go	Tue Jan 03 16:56:28 2012 -0700
+++ b/roster.go	Thu Jan 05 14:25:40 2012 -0700
@@ -50,8 +50,8 @@
 			return false
 		}
 		cl.roster = make(map[string] *RosterItem, len(rq.Item))
-		for _, item := range(rq.Item) {
-			cl.roster[item.Jid] = &item
+		for i, item := range(rq.Item) {
+			cl.roster[item.Jid] = &rq.Item[i]
 		}
 		ch <- nil
 		return false
@@ -95,11 +95,11 @@
 func (cl *Client) maybeUpdateRoster(st Stanza) {
 	rq, ok := st.GetNested().(*RosterQuery)
 	if st.GetName() == "iq" && st.GetType() == "set" && ok {
-		for _, item := range(rq.Item) {
+		for i, item := range(rq.Item) {
 			if item.Subscription == "remove" {
 				cl.roster[item.Jid] = nil
 			} else {
-				cl.roster[item.Jid] = &item
+				cl.roster[item.Jid] = &rq.Item[i]
 			}
 		}
 	}