From 806ecdf8e821909cdae7e7bb6208d12d89640db2 Mon Sep 17 00:00:00 2001 From: fhgffy <102001626+fhgffy@users.noreply.github.com> Date: Mon, 5 Oct 2026 13:00:47 +0800 Subject: [PATCH] Handle NULL database strings safely SQLite returns a null pointer for SQL NULL. Passing it to rust::Str crashes the daemon when a query result contains a NULL column. Return an empty Rust string for NULL while leaving the raw C++ getter unchanged, so callers that distinguish NULL can keep doing so. Fixes: #10131 Assisted-by: GPT-6 --- native/src/core/include/sqlite.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/native/src/core/include/sqlite.hpp b/native/src/core/include/sqlite.hpp index caa5b1c97..782a9a32c 100644 --- a/native/src/core/include/sqlite.hpp +++ b/native/src/core/include/sqlite.hpp @@ -20,7 +20,10 @@ extern const char *(*sqlite3_errstr)(int); // Transparent wrappers of sqlite3_stmt struct DbValues { const char *get_text(int index) const; - rust::Str get_str(int index) const { return get_text(index); } + rust::Str get_str(int index) const { + auto text = get_text(index); + return text ? rust::Str(text) : rust::Str(); + } int get_int(int index) const; ~DbValues() = delete; };