From 47ecc5d37f77da25e4469fe54dcc1c2270587076 Mon Sep 17 00:00:00 2001 From: Francisco Souza Date: Fri, 13 Feb 2015 18:10:47 -0200 Subject: [PATCH] repository: prevent nil pointer dereference in error detection --- repository/repository.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/repository/repository.go b/repository/repository.go index 7b6557b..d53e70f 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -312,10 +312,13 @@ func GrantAccess(rNames, uNames []string, readOnly bool) error { } else { info, err = conn.Repository().UpdateAll(bson.M{"_id": bson.M{"$in": rNames}}, bson.M{"$addToSet": bson.M{"users": bson.M{"$each": uNames}}}) } + if err != nil { + return err + } if info.Updated < 1 { return mgo.ErrNotFound } - return err + return nil } // RevokeAccess revokes write permission from users in all specified