Fix leaking a cursor

Change-Id: I1953ea995e83eb4f787f28b0fd510805e4ffc6eb