From 096226bf05808c1aeff07089c582196c167de926 Mon Sep 17 00:00:00 2001 From: Juan de Bruin Date: Tue, 4 Jun 2024 17:38:06 +0200 Subject: [PATCH] examples: check array length before access (#21641) --- examples/vweb_fullstack/src/auth_services.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/vweb_fullstack/src/auth_services.v b/examples/vweb_fullstack/src/auth_services.v index 798b9354774554..edd14c0412645d 100644 --- a/examples/vweb_fullstack/src/auth_services.v +++ b/examples/vweb_fullstack/src/auth_services.v @@ -37,6 +37,9 @@ fn (mut app App) service_auth(username string, password string) !string { users := sql db { select from User where username == username }! + if users.len == 0 { + return error('user not found') + } user := users.first() if user.username != username { return error('user not found')