mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
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
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user