Skip to content

Commit 096226b

Browse files
authored
examples: check array length before access (#21641)
1 parent 1e86e06 commit 096226b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/vweb_fullstack/src/auth_services.v

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ fn (mut app App) service_auth(username string, password string) !string {
3737
users := sql db {
3838
select from User where username == username
3939
}!
40+
if users.len == 0 {
41+
return error('user not found')
42+
}
4043
user := users.first()
4144
if user.username != username {
4245
return error('user not found')

0 commit comments

Comments
 (0)