NPE on Iterate if no results are iterated #2047

Closed
opened 2021-09-13 11:39:46 +00:00 by zeripath · 1 comment
Contributor

From: https://github.com/go-gitea/gitea/issues/17030

There is an apparent regression within xorm 1.2.2 - in xorm/rows.go:90-93

// Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
func (rows *Rows) Err() error {
	return rows.rows.Err()
}

Should probably be:

// Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
func (rows *Rows) Err() error {
	if rows.rows == nil {
		return nil
	}
	return rows.rows.Err()
}

This regression apperars to cause an NPE if there are no rows returned in Iterate.

From: https://github.com/go-gitea/gitea/issues/17030 There is an apparent regression within xorm 1.2.2 - in `xorm/rows.go`:90-93 ```go // Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close. func (rows *Rows) Err() error { return rows.rows.Err() } ``` Should probably be: ```go // Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close. func (rows *Rows) Err() error { if rows.rows == nil { return nil } return rows.rows.Err() } ``` This regression apperars to cause an NPE if there are no rows returned in Iterate.
Author
Contributor

Fixed by #2046

Fixed by #2046
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#2047
No description provided.