db.mysql: fix invalid memory access in exec_one for returned rows with NULL fields (#21317)

This commit is contained in:
Roman 2024-04-20 16:52:58 +07:00 committed by GitHub
parent e235641c29
commit 2192d9b1e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 10 deletions

View file

@ -323,7 +323,7 @@ pub fn (db &DB) exec_one(query string) !Row {
mut row := Row{}
for i in 0 .. num_cols {
if unsafe { row_vals == &u8(0) } {
if unsafe { row_vals == &u8(0) } || unsafe { row_vals[i] == nil } {
row.vals << ''
} else {
row.vals << mystring(unsafe { &u8(row_vals[i]) })