From 4f5603f3dbac5e5bb447f64e09e322159d00cb60 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Tue, 21 Jul 2009 17:32:31 +0000 Subject: [PATCH] DBD-SQLite: fixed the perl 5.8 segfault issue for set_authorizer --- dbdimp.c | 30 ++++++++++++++++++++++++++---- t/36_hooks.t | 5 +---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/dbdimp.c b/dbdimp.c index 39e8e41..aff3229 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -1521,10 +1521,32 @@ sqlite_db_authorizer_dispatcher ( PUSHMARK(SP); XPUSHs( sv_2mortal ( newSViv ( action_code ) ) ); - XPUSHs( sv_2mortal ( newSVpv ( details_1, 0 ) ) ); - XPUSHs( sv_2mortal ( newSVpv ( details_2, 0 ) ) ); - XPUSHs( sv_2mortal ( newSVpv ( details_3, 0 ) ) ); - XPUSHs( sv_2mortal ( newSVpv ( details_4, 0 ) ) ); + + /* these ifs are ugly but without them, perl 5.8 segfaults */ + if (details_1 == NULL) { + XPUSHs( NULL ); + } + else { + XPUSHs( sv_2mortal ( newSVpv ( details_1, 0 ) ) ); + } + if (details_2 == NULL) { + XPUSHs( NULL ); + } + else { + XPUSHs( sv_2mortal ( newSVpv ( details_2, 0 ) ) ); + } + if (details_3 == NULL) { + XPUSHs( NULL ); + } + else { + XPUSHs( sv_2mortal ( newSVpv ( details_3, 0 ) ) ); + } + if (details_4 == NULL) { + XPUSHs( NULL ); + } + else { + XPUSHs( sv_2mortal ( newSVpv ( details_4, 0 ) ) ); + } PUTBACK; n_retval = call_sv(authorizer, G_SCALAR); diff --git a/t/36_hooks.t b/t/36_hooks.t index 5f496c8..c97a6c6 100644 --- a/t/36_hooks.t +++ b/t/36_hooks.t @@ -112,10 +112,7 @@ foreach my $call_func (@CALL_FUNCS) { : DBD::SQLite::OK; return $retval; }; - unless ($] < 5.010) { - # FIXME: this line may cause segfalut - $dbh->$call_func($authorizer, "set_authorizer"); - } + $dbh->$call_func($authorizer, "set_authorizer"); # try an insert (should be authorized) and check authorizer args $dbh->do("INSERT INTO hook_test VALUES ('auth_test')");