mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
fetching attributes from a statement handle whose database handle is disabled should return an error, instead of coredump under perl with -fsanitize=address
- reported by Peter Rabbitson
This commit is contained in:
parent
43bcd31784
commit
1d665d8661
2 changed files with 21 additions and 1 deletions
5
dbdimp.c
5
dbdimp.c
|
@ -1312,6 +1312,11 @@ sqlite_st_FETCH_attrib(SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
croak_if_db_is_null();
|
croak_if_db_is_null();
|
||||||
croak_if_stmt_is_null();
|
croak_if_stmt_is_null();
|
||||||
|
|
||||||
|
if (!DBIc_ACTIVE(imp_dbh)) {
|
||||||
|
sqlite_error(sth, -2, "attempt to fetch on inactive database handle");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (strEQ(key, "sqlite_unprepared_statements")) {
|
if (strEQ(key, "sqlite_unprepared_statements")) {
|
||||||
return sv_2mortal(newSVpv(imp_sth->unprepared_statements, 0));
|
return sv_2mortal(newSVpv(imp_sth->unprepared_statements, 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ BEGIN {
|
||||||
$^W = 1;
|
$^W = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
use Test::More tests => 4;
|
use Test::More tests => 7;
|
||||||
use lib "t/lib";
|
use lib "t/lib";
|
||||||
use SQLiteTest;
|
use SQLiteTest;
|
||||||
|
|
||||||
|
@ -33,3 +33,18 @@ like(
|
||||||
qr/attempt to execute on inactive database handle/,
|
qr/attempt to execute on inactive database handle/,
|
||||||
'Got the expected warning',
|
'Got the expected warning',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@warning = ();
|
||||||
|
SCOPE: {
|
||||||
|
local $SIG{__WARN__} = sub { push @warning, @_; return };
|
||||||
|
my $ret = eval { $sth->{NUM_OF_PARAMS}; };
|
||||||
|
# we need PrintError => 1, or warn $@ if $@;
|
||||||
|
ok !$ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
is( scalar(@warning), 1, 'Got 1 warning' );
|
||||||
|
like(
|
||||||
|
$warning[0],
|
||||||
|
qr/attempt to fetch on inactive database handle/,
|
||||||
|
'Got the expected warning',
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue