Merge pull request #1424 from mattn/fix-preupdate-null-deref
Check preupdate value fetch result to avoid NULL dereference
This commit is contained in:
@@ -59,13 +59,17 @@ func (d *SQLitePreUpdateData) row(dest []any, new bool) error {
|
|||||||
for i := 0; i < d.Count() && i < len(dest); i++ {
|
for i := 0; i < d.Count() && i < len(dest); i++ {
|
||||||
var val *C.sqlite3_value
|
var val *C.sqlite3_value
|
||||||
var src any
|
var src any
|
||||||
|
var rc C.int
|
||||||
|
|
||||||
// Initially I tried making this just a function pointer argument, but
|
// Initially I tried making this just a function pointer argument, but
|
||||||
// it's absurdly complicated to pass C function pointers.
|
// it's absurdly complicated to pass C function pointers.
|
||||||
if new {
|
if new {
|
||||||
C.sqlite3_preupdate_new(d.Conn.db, C.int(i), &val)
|
rc = C.sqlite3_preupdate_new(d.Conn.db, C.int(i), &val)
|
||||||
} else {
|
} else {
|
||||||
C.sqlite3_preupdate_old(d.Conn.db, C.int(i), &val)
|
rc = C.sqlite3_preupdate_old(d.Conn.db, C.int(i), &val)
|
||||||
|
}
|
||||||
|
if rc != C.SQLITE_OK {
|
||||||
|
return Error{Code: ErrNo(rc)}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch C.sqlite3_value_type(val) {
|
switch C.sqlite3_value_type(val) {
|
||||||
|
|||||||
Reference in New Issue
Block a user