Skip to content

Commit eca7d7c

Browse files
committed
Fix a NULL profile dereference in dbi_profile()
hv_fetch() documentation requires checking for NULL and the code does that. But then calls SvOK(profile) uncoditionally two lines later. This patch fixes it.
1 parent a0e1755 commit eca7d7c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

DBI.xs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,8 +2888,12 @@ dbi_profile(SV *h, imp_xxh_t *imp_xxh, SV *statement_sv, SV *method, NV t1, NV t
28882888
mg_get(profile); /* FETCH */
28892889
if (!profile || !SvROK(profile)) {
28902890
DBIc_set(imp_xxh, DBIcf_Profile, 0); /* disable */
2891-
if (SvOK(profile) && !PL_dirty)
2892-
warn("Profile attribute isn't a hash ref (%s,%ld)", neatsvpv(profile,0), (long)SvTYPE(profile));
2891+
if (!PL_dirty) {
2892+
if (!profile)
2893+
warn("Profile attribute does not exist");
2894+
else if (SvOK(profile))
2895+
warn("Profile attribute isn't a hash ref (%s,%ld)", neatsvpv(profile,0), (long)SvTYPE(profile));
2896+
}
28932897
return &PL_sv_undef;
28942898
}
28952899

0 commit comments

Comments
 (0)