mirror of
https://github.com/vlang/v.git
synced 2025-09-14 18:06:48 -04:00
builtin: fix undefined read s[0], from ''.is_lower() and ''.is_upper() in c7af2c2
This commit is contained in:
parent
c7af2c21d1
commit
d66de0c514
@ -1524,7 +1524,7 @@ pub fn (s string) to_lower() string {
|
||||
// Example: assert 'hello developer'.is_lower() == true
|
||||
@[direct_array_access]
|
||||
pub fn (s string) is_lower() bool {
|
||||
if s[0].is_digit() {
|
||||
if s.len > 0 && s[0].is_digit() {
|
||||
return false
|
||||
}
|
||||
for i in 0 .. s.len {
|
||||
@ -1558,7 +1558,7 @@ pub fn (s string) to_upper() string {
|
||||
// Example: assert 'HELLO V'.is_upper() == true
|
||||
@[direct_array_access]
|
||||
pub fn (s string) is_upper() bool {
|
||||
if s[0].is_digit() {
|
||||
if s.len > 0 && s[0].is_digit() {
|
||||
return false
|
||||
}
|
||||
for i in 0 .. s.len {
|
||||
|
Loading…
x
Reference in New Issue
Block a user