mirror of https://github.com/mattn/go-sqlite3.git
Merge pull request #345 from joeshaw/backup-finalizer-fix
fix double free in SQLiteBackup.Close() on error
This commit is contained in:
commit
955dae4ebd
|
@ -65,10 +65,15 @@ func (b *SQLiteBackup) Finish() error {
|
||||||
|
|
||||||
func (b *SQLiteBackup) Close() error {
|
func (b *SQLiteBackup) Close() error {
|
||||||
ret := C.sqlite3_backup_finish(b.b)
|
ret := C.sqlite3_backup_finish(b.b)
|
||||||
|
|
||||||
|
// sqlite3_backup_finish() never fails, it just returns the
|
||||||
|
// error code from previous operations, so clean up before
|
||||||
|
// checking and returning an error
|
||||||
|
b.b = nil
|
||||||
|
runtime.SetFinalizer(b, nil)
|
||||||
|
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return Error{Code: ErrNo(ret)}
|
return Error{Code: ErrNo(ret)}
|
||||||
}
|
}
|
||||||
b.b = nil
|
|
||||||
runtime.SetFinalizer(b, nil)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue